Package java.net

Examples of java.net.MulticastSocket


        this.service = service;
        this.sendFrequency = sendFrequency;
    }
   
    protected void setupSocket() throws IOException {
        if (mcastBindAddress != null) socket = new MulticastSocket(new java.net.
            InetSocketAddress(mcastBindAddress, port));
        else socket = new MulticastSocket(port);
        if (mcastBindAddress != null) {
      if(log.isInfoEnabled())
                log.info("Setting multihome multicast interface to:" +
                         mcastBindAddress);
            socket.setInterface(mcastBindAddress);
View Full Code Here


      if (started)
      {
         return;
      }

      socket = new MulticastSocket(groupPort);

      if (localBindAddress != null)
      {
         socket.setInterface(localBindAddress);
      }
View Full Code Here

         // HORNETQ-874
         if (checkForLinux() || checkForSolaris() || checkForHp())
         {
            try
            {
               receivingSocket = new MulticastSocket(new InetSocketAddress(groupAddress, groupPort));
            }
            catch (IOException e)
            {
               HornetQClientLogger.LOGGER.ioDiscoveryError(groupAddress.getHostAddress(), groupAddress instanceof Inet4Address ? "IPv4" : "IPv6");

               receivingSocket = new MulticastSocket(groupPort);
            }
         }
         else
         {
            receivingSocket = new MulticastSocket(groupPort);
         }

         if (localAddress != null)
         {
            receivingSocket.setInterface(localAddress);
View Full Code Here

        DatagramPacket send_packet, recv_packet;
        byte[] send_buf;
        byte[] recv_buf=new byte[2100];

        if(local) {
            MulticastSocket send_sock=new MulticastSocket(PORT);
            send_sock.setTrafficClass(8);
            MulticastSocket recv_sock=new MulticastSocket(PORT);
            recv_sock.joinGroup(GROUP);
            recv_packet=new DatagramPacket(recv_buf, 0, recv_buf.length);
            for(int i=0; i < 10; i++) {
                start=System.currentTimeMillis();
                send_buf=Util.objectToByteBuffer(start);
                send_packet=new DatagramPacket(send_buf, 0, send_buf.length, GROUP, PORT);
                send_sock.send(send_packet);
                recv_sock.receive(recv_packet);
                start=((Long)Util.objectFromByteBuffer(recv_buf, recv_packet.getOffset(), recv_packet.getLength())).longValue();
                System.out.println("took " + (System.currentTimeMillis() - start) + " ms");
                Util.sleep(1000);
            }
            return;
        }

        if(sender) {
            MulticastSocket send_sock=new MulticastSocket(PORT);
            send_sock.setTrafficClass(8);
            for(int i=0; i < 10; i++) {
                start=System.currentTimeMillis();
                send_buf=Util.objectToByteBuffer(start);
                send_packet=new DatagramPacket(send_buf, 0, send_buf.length, GROUP, PORT);
                send_sock.send(send_packet);
                Util.sleep(1000);
            }
        }
        else {
            MulticastSocket recv_sock=new MulticastSocket(PORT);
            recv_sock.joinGroup(GROUP);
            recv_packet=new DatagramPacket(recv_buf, 0, recv_buf.length);
            System.out.println("receiver started");
            for(;;) {
                recv_sock.receive(recv_packet);
                start=((Long)Util.objectFromByteBuffer(recv_buf, recv_packet.getOffset(), recv_packet.getLength())).longValue();
                System.out.println("took " + (System.currentTimeMillis() - start) + " ms");
            }
        }
    }
View Full Code Here

            this.channel=channel;
            this.matrix=matrix;
            this.jg=jg;
            num_msgs=matrix.length;
            if(group_addr != null) {
                sock=new MulticastSocket(group_port);
                sock.joinGroup(group_addr);
            }
        }
View Full Code Here

            bind_addr=InetAddress.getLocalHost();

        ucast_sock=new DatagramSocket(0, bind_addr);
        ucast_sock.setReceiveBufferSize(max_receiver_buffer_size);
        ucast_sock.setSendBufferSize(max_send_buffer_size);
        mcast_sock=new MulticastSocket(mcast_port);
        mcast_sock.setReceiveBufferSize(max_receiver_buffer_size);
        mcast_sock.setSendBufferSize(max_send_buffer_size);
        if(bind_addr != null)
            mcast_sock.setInterface(bind_addr);
        mcast_sock.joinGroup(mcast_addr);
View Full Code Here

      {
         // use this to bind so multicast will work w/o network
         this.bindAddr = localHost;
      }
      SocketAddress saddr = new InetSocketAddress(bindAddr, port);
      socket = new MulticastSocket(saddr);
      socket.joinGroup(addr);

      super.start();

      if(listener == null)
View Full Code Here

      {
         return;
      }

      try {
         socket = new MulticastSocket(groupPort);

         if (localBindAddress != null)
         {
            socket.setInterface(localBindAddress);
         }
View Full Code Here

         // HORNETQ-874
         if (checkForLinux() || checkForSolaris() || checkForHp())
         {
            try
            {
               receivingSocket = new MulticastSocket(new InetSocketAddress(groupAddress, groupPort));
            }
            catch (IOException e)
            {
               HornetQClientLogger.LOGGER.ioDiscoveryError(groupAddress.getHostAddress(), groupAddress instanceof Inet4Address ? "IPv4" : "IPv6");

               receivingSocket = new MulticastSocket(groupPort);
            }
         }
         else
         {
            receivingSocket = new MulticastSocket(groupPort);
         }

         if (localAddress != null)
         {
            receivingSocket.setInterface(localAddress);
View Full Code Here

        DatagramPacket packet;
        byte buf[]=null;
        byte[] recv_buf;

        Receiver(InetAddress mcast_addr, InetAddress bind_interface, int port) throws Exception {
            sock=new MulticastSocket(port);
            if(bind_interface != null)
                sock.setInterface(bind_interface);
            sock.joinGroup(mcast_addr);
            System.out.println("Socket=" + sock.getLocalAddress() + ':' + sock.getLocalPort() + ", bind interface=" +
                    sock.getInterface());
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.