Package java.net

Examples of java.net.MulticastSocket.joinGroup()


            return existingKey;
        }

        boolean success = false;
        try {
            msocket.joinGroup(mcastaddr, interf);
            success = true;
            return newKey;
        } finally {
            if (!success) {
                mcastKeys.remove(newKey);
View Full Code Here


                String multicastGroup = System.getProperty("hazelcast.multicast.group");
                if (multicastGroup == null) {
                    multicastGroup = multicastConfig.getMulticastGroup();
                }
                multicastConfig.setMulticastGroup(multicastGroup);
                multicastSocket.joinGroup(InetAddress.getByName(multicastGroup));
                multicastSocket.setSoTimeout(1000);
                mcService = new MulticastService(this, multicastSocket);
                mcService.addMulticastListener(new NodeMulticastListener(this));
            }
        } catch (Exception e) {
View Full Code Here

        InetAddress inetAddress = InetAddress.getByName(host);

        InetSocketAddress address = new InetSocketAddress(inetAddress, port);

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

        if (ttl != null) {
            multicast.setTimeToLive(ttl);
        }
View Full Code Here

                ms.setSoTimeout(0);
                ms.setTimeToLive(TTL);
                if (!ms.getBroadcast()) {
                    ms.setBroadcast(true);
                }
                ms.joinGroup(ia);

                list.add(ms);

                log.debug(String.format("Created MulticastSocket for '%1$s:%2$s' on network adapter: %3$s", ia.getHostName(), port, ni));
View Full Code Here

            if (group != null)
            {
               MulticastSocket socket = new MulticastSocket(bindAddress);

               m_socket = socket;
               socket.joinGroup(group);
            }
            else if (bindAddress.getPort() <= 0)
            {
               DatagramChannel channel = DatagramChannel.open();
View Full Code Here

        @Override
        public void run() {
            try (MulticastSocket s = new MulticastSocket(PORT)) {
                s.setLoopbackMode(false);
                s.joinGroup(INET_ADDRESS);
                DatagramPacket p = new DatagramPacket(new byte[4], 4);
                p.setAddress(INET_ADDRESS);
                p.setPort(PORT);
                while (run) {
                    s.receive(p);
View Full Code Here

        @Override
        public void run() {
            try (MulticastSocket s = new MulticastSocket(PORT)) {
                s.setLoopbackMode(false);
                s.joinGroup(INET_ADDRESS);
                DatagramPacket p = new DatagramPacket(new byte[4], 4);
                p.setAddress(INET_ADDRESS);
                p.setPort(PORT);
                long counter = 0;
                String msg;
View Full Code Here

        MulticastSocket socket = null;
        try {
            // open a multicast socket
            socket = new MulticastSocket(PORT);
            socket.setLoopbackMode(false); // false indecates doing loop back
            socket.joinGroup(InetAddress.getByName(ADDRESS));

            // send the datagram
            byte[] sendData = message.getBytes();
            DatagramPacket sendDatagram = new DatagramPacket(sendData, 0,
                    sendData.length, new InetSocketAddress(InetAddress
View Full Code Here

        MulticastSocket socket = null;
        try {
            // open a multicast socket
            socket = new MulticastSocket(PORT);
            socket.setLoopbackMode(false); // false indecates doing loop back
            socket.joinGroup(InetAddress.getByName(ADDRESS));

            // send the datagram
            byte[] sendData = message.getBytes();
            DatagramPacket sendDatagram = new DatagramPacket(sendData, 0,
                    sendData.length, new InetSocketAddress(InetAddress
View Full Code Here

    }

    protected DatagramSocket createSocket(int port, InetAddress inetAddress) throws IOException
    {
        MulticastSocket socket = new MulticastSocket(port);
        socket.joinGroup(inetAddress);
        return socket;
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.