Package java.net

Examples of java.net.MulticastSocket


  public AnnounceThread() throws IOException {
      super("discovery announcement");
      setDaemon(true);
      if (multicastInterfaces == null || multicastInterfaces.length > 0)
      {
    socket = new MulticastSocket();
    socket.setTimeToLive(
        multicastAnnouncementConstraints.getMulticastTimeToLive(
      DEFAULT_MULTICAST_TTL));
      } else {
    socket = null;
View Full Code Here


  /** Create a daemon thread */
  public AnnouncementListener() throws IOException {
      super("multicast discovery announcement listener");
      setDaemon(true);
      sock = new MulticastSocket(Constants.discoveryPort);
            switch(nicsToUse) {
                case NICS_USE_ALL:
                    /* Using all interfaces. Skip (but report) any interfaces
                     * that are "bad" or not configured for multicast.
                     */
 
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

        InetAddress inetAddress = InetAddress.getByName(host);

        InetSocketAddress address = new InetSocketAddress(inetAddress, port);

        MulticastSocket multicast = new MulticastSocket(port);
        multicast.joinGroup(inetAddress);


        final MulticastSocket s = multicast;
        if (options.has("reuse-address")) s.setReuseAddress(options.get("reuse-address", false));
        if (options.has("broadcast")) s.setBroadcast(options.get("broadcast", false));
        if (options.has("loopback-mode")) s.setLoopbackMode(options.get("loopback-mode", false));
        if (options.has("send-buffer-size")) s.setSendBufferSize(options.get("send-buffer-size", 0));
        if (options.has("receive-buffer-size")) s.setReceiveBufferSize(options.get("receive-buffer-size", 0));
        if (options.has("so-timeout")) s.setSoTimeout(options.get("so-timeout", 0));
        if (options.has("time-to-live")) s.setTimeToLive(options.get("time-to-live", 0));
        if (options.has("traffic-class")) s.setTrafficClass(options.get("traffic-class", 0));

        System.out.println("Connected");
        print("host", host);
        print("port", port);
        System.out.println();

        System.out.println("Socket");
        print("broadcast", s.getBroadcast());
        print("loopback-mode", s.getLoopbackMode());
        print("receive-buffer-size", s.getReceiveBufferSize());
        print("reuse-address", s.getReuseAddress());
        print("send-buffer-size", s.getSendBufferSize());
        print("so-timeout", s.getSoTimeout());
        print("time-to-live", s.getTimeToLive());
        print("traffic-class", s.getTrafficClass());
        System.out.println();

        if (options.has("send")) {
            String send = options.get("send", "");
            long rate = options.get("rate", 1000);
View Full Code Here

            group = InetAddress.getByName(DNSConstants.MDNS_GROUP);
        }
        if (socket != null) {
            this.closeMulticastSocket();
        }
        socket = new MulticastSocket(DNSConstants.MDNS_PORT);
        if ((hostInfo != null) && (localHost.getInterface() != null)) {
            socket.setNetworkInterface(hostInfo.getInterface());
        }
        socket.setTimeToLive(255);
        socket.joinGroup(group);
View Full Code Here

        this.ilca = lca;

        try
        {

            m_localSocket = new MulticastSocket();

            // Remote address.
            m_multicastAddress =
                InetAddress.getByName( lca.getUdpMulticastAddr() );
        }
View Full Code Here

        log.debug( "constructing listener, " + multicastAddressString + ":" + multicastPort );

        try
        {
            m_socket = new MulticastSocket( multicastPort );
            m_socket.joinGroup( InetAddress.getByName( multicastAddressString ) );
        }
        catch ( IOException e )
        {
            log.error( e );
View Full Code Here

            "Listening for distributed nodes on IP multicast " + iManager.networkMulticastAddress + ":"
                + iManager.networkMulticastPort);

    dgram = new DatagramPacket(recvBuffer, recvBuffer.length);
    try {
      socket = new MulticastSocket(iManager.networkMulticastPort);
      socket.joinGroup(iManager.networkMulticastAddress);
    } catch (IOException e) {
      throw new OIOException(
          "Can't startup the Discovery Listener service to catch distributed server nodes, probably the IP MULTICAST is disabled in current network configuration: "
              + e.getMessage());
View Full Code Here

 
  private void connect()
  {
    System.out.println("MultiCAST : Try to connect to server " + m_group + " on port " + m_port);
    try{
      m_ms = new MulticastSocket(m_port);
      m_ms.joinGroup(m_group);
     
      System.out.println(m_group + " on port " + m_port + " is up and running.");
     
      m_connected = true;
View Full Code Here

        this.channel = channel;
    }

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

        while (channel.isOpen()) {
            synchronized (channel.interestOpsLock) {
                while (!channel.isReadable()) {
                    try {
                        // notify() is not called at all.
                        // close() and setInterestOps() calls Thread.interrupt()
                        channel.interestOpsLock.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 (InterruptedIOException e) {
                // Can happen on interruption.
                // Keep receiving unless the channel is closed.
                continue;
            } catch (Throwable t) {
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.