Examples of joinGroup()


Examples of java.net.MulticastSocket.joinGroup()

        String message = "Hello, world!";
        String longerMessage = message + " again.";
        String veryLongMessage = longerMessage + " Forever!";

        socket.joinGroup(group);
        socket.setSoTimeout(5000); // prevent eternal block in
                                   // socket.receive()
        // send & recieve packet
        byte[] sendData = message.getBytes();
        DatagramPacket sendDatagram = new DatagramPacket(sendData, 0,
View Full Code Here

Examples of java.net.MulticastSocket.joinGroup()

        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

Examples of java.net.MulticastSocket.joinGroup()

        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

Examples of java.net.MulticastSocket.joinGroup()

        Thread receiver = new Thread() {
            public void run() {
                try {
                    MulticastSocket s = new MulticastSocket(port);
                    s.joinGroup(InetAddress.getByName(group));

                    // Create a DatagramPacket and do a receive
                    byte buf[] = new byte[1024];
                    DatagramPacket pack = new DatagramPacket(buf, buf.length);
                    s.receive(pack);
View Full Code Here

Examples of java.net.MulticastSocket.joinGroup()

                try {
                    //fake a discovery server to send back some canned messages.
                    InetAddress address = InetAddress.getByName("239.255.255.250");
                    MulticastSocket s = new MulticastSocket(Integer.parseInt(PORT));
                    s.setBroadcast(true);
                    s.joinGroup(address);
                    s.setReceiveBufferSize(64 * 1024);
                    s.setSoTimeout(5000);
                    byte[] bytes = new byte[64 * 1024];
                    DatagramPacket p = new DatagramPacket(bytes, bytes.length, address, Integer.parseInt(PORT));
                    s.receive(p);
View Full Code Here

Examples of java.net.MulticastSocket.joinGroup()

         }
         s.setSoTimeout(timeout);
         s.setTimeToLive(ttl);
         if(log.isTraceEnabled())
            log.trace("TTL on multicast discovery socket is " + ttl);
         s.joinGroup(iaGroup);
         if (trace)
            log.trace("MulticastSocket: " + s);
         DatagramPacket packet;
         // Send a request optionally restricted to a cluster partition
         StringBuffer data = new StringBuffer("GET_ADDRESS");
View Full Code Here

Examples of java.net.MulticastSocket.joinGroup()

                socket.setReuseAddress(true);
                socket.setReceiveBufferSize(64 * 1024);
                socket.setSendBufferSize(64 * 1024);
                socket.setTimeToLive(1);
                socket.bind(new InetSocketAddress(isa.getPort()));
                socket.joinGroup(isa.getAddress());
                mcast = socket;
                queue.execute(new MCastListener());
            } else {
               
                acceptor = new NioDatagramAcceptor();
View Full Code Here

Examples of java.net.MulticastSocket.joinGroup()

        Thread receiver = new Thread() {
            public void run() {
                try {
                    MulticastSocket s = new MulticastSocket(port);
                    s.joinGroup(InetAddress.getByName(group));

                    // Create a DatagramPacket and do a receive
                    byte buf[] = new byte[1024];
                    DatagramPacket pack = new DatagramPacket(buf, buf.length);
                    s.receive(pack);
View Full Code Here

Examples of java.net.MulticastSocket.joinGroup()

    public static void main(String[] args) throws Exception {

        MulticastSocket msocket = new MulticastSocket(port);
        InetAddress group = InetAddress.getByName(ip);
        msocket.joinGroup(group);

        byte[] inbuf = new byte[1024];
        DatagramPacket packet = new DatagramPacket(inbuf, inbuf.length);

        // Wait for packet
View Full Code Here

Examples of java.net.MulticastSocket.joinGroup()

      public void run() {
        try {
         
          // Start Multicast Socket and listen for Requests
          final MulticastSocket mSock = new MulticastSocket(SERVICE_PORT);
          mSock.joinGroup(SERVICE_REQUEST_IP);

          // Infinite Loop
          while (true) {
            // Buffer (for Greeting Message)
            byte[] msg = new byte[GREET_MSG.getBytes("UTF-8").length];
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.