Package java.net

Examples of java.net.MulticastSocket


        public MulticastServer(SocketAddress anAddress, int aPort,
        NetworkInterface netInterface) throws java.io.IOException {
      rbuf = new byte[512];
      rbuf[0] = -1;
      rdp = new DatagramPacket(rbuf, rbuf.length);
      ms = new MulticastSocket(aPort);
      ms.setSoTimeout(2000);
            groupSockAddr = anAddress;
            groupNI = netInterface;
            ms.joinGroup(groupSockAddr, groupNI);
    }
View Full Code Here


   
    protected void setupSocket() throws IOException {
        if (mcastBindAddress != null) {
            try {
                log.info("Attempting to bind the multicast socket to "+address+":"+port);
                socket = new MulticastSocket(new InetSocketAddress(address,port));
            } catch (BindException e) {
                /*
                 * On some platforms (e.g. Linux) it is not possible to bind
                 * to the multicast address. In this case only bind to the
                 * port.
                 */
                log.info("Binding to multicast address, failed. Binding to port only.");
                socket = new MulticastSocket(port);
            }
        } else {
            socket = new MulticastSocket(port);
        }
        socket.setLoopbackMode(localLoopbackDisabled); //hint if we want disable loop back(local machine) messages
        if (mcastBindAddress != null) {
            if(log.isInfoEnabled())
                log.info("Setting multihome multicast interface to:" +mcastBindAddress);
View Full Code Here

    private void newSocket() throws IOException {
        InetAddress inetAddress = InetAddress.getByName(host);

        this.address = new InetSocketAddress(inetAddress, port);

        multicast = new MulticastSocket(port);
        multicast.setLoopbackMode(loopbackMode);
        multicast.setTimeToLive(timeToLive);
        multicast.joinGroup(inetAddress);
        multicast.setSoTimeout((int) heartRate);
    }
View Full Code Here

    }

    public MulticastSearch(String host, int port) throws IOException {
        InetAddress inetAddress = InetAddress.getByName(host);

        multicast = new MulticastSocket(port);
        multicast.joinGroup(inetAddress);
        multicast.setSoTimeout(500);
    }
View Full Code Here

            if (discoveryURI == null) {
                discoveryURI = new URI(DEFAULT_DISCOVERY_URI_STRING);
            }
            this.inetAddress = InetAddress.getByName(discoveryURI.getHost());
            this.sockAddress = new InetSocketAddress(this.inetAddress, discoveryURI.getPort());
            mcast = new MulticastSocket(discoveryURI.getPort());
            mcast.setLoopbackMode(loopBackMode);
            mcast.setTimeToLive(getTimeToLive());
            mcast.joinGroup(inetAddress);
            mcast.setSoTimeout((int)keepAliveInterval);
            runner = new Thread(this);
View Full Code Here

        this.channel = channel;
    }

    public void run() {
        channel.workerThread = Thread.currentThread();
        final MulticastSocket socket = channel.socket;

        while (channel.isOpen()) {
            synchronized (this) {
                while (!channel.isReadable()) {
                    try {
                        // notify() is not called at all.
                        // close() and setInterestOps() calls Thread.interrupt()
                        this.wait();
                    } catch (InterruptedException e) {
                        if (!channel.isOpen()) {
                            break;
                        }
                    }
                }
            }

            ReceiveBufferSizePredictor predictor =
                channel.getConfig().getReceiveBufferSizePredictor();

            byte[] buf = new byte[predictor.nextReceiveBufferSize()];
            DatagramPacket packet = new DatagramPacket(buf, buf.length);
            try {
                socket.receive(packet);
            } catch (Throwable t) {
                if (!channel.socket.isClosed()) {
                    fireExceptionCaught(channel, t);
                }
                break;
View Full Code Here

            ChannelSink sink) {

        super(null, factory, pipeline, sink);

        try {
            socket = new MulticastSocket(null);
        } catch (IOException e) {
            throw new ChannelException("Failed to open a datagram socket.", e);
        }
        config = new DefaultDatagramChannelConfig(socket);
    }
View Full Code Here

    }

    public UDPBroadcastThread(Jenkins jenkins) throws IOException {
        super("Jenkins UDP "+PORT+" monitoring thread");
        this.jenkins = jenkins;
        mcs = new MulticastSocket(PORT);
    }
View Full Code Here

    // read system env setting for Ganglia server address
    final String gangliaHostAddress = System.getProperty("ganglia.host");
    this.inetAddress = InetAddress.getByName(gangliaHostAddress);

    // create multicast socket, join group, and send meta data packet
    socket = new MulticastSocket(DEFAULT_PORT);
  }
View Full Code Here

   * @throws IOException
   */
  public GConnector(String multicastAddress) throws IOException {
    this.inetAddress = InetAddress.getByName(multicastAddress);
    // create multicast socket, join group, and send meta data packet
    socket = new MulticastSocket(DEFAULT_PORT);
  }
View Full Code Here

TOP

Related Classes of java.net.MulticastSocket

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.