Hello,

     First I'd like to say I am really pleased with your course layout thus 
far.  I seem to be having a problem compiling your sample multicast 
networking program on my mac.  


The exception/compiler output is as follows:

run:
MulticastSocket is created at port 5000
Exception in thread "main" java.net.SocketException: Can't assign requested 
address
at java.net.PlainDatagramSocketImpl.join(Native Method)
at 
java.net.AbstractPlainDatagramSocketImpl.join(AbstractPlainDatagramSocketImpl.java:179)
at java.net.MulticastSocket.joinGroup(MulticastSocket.java:323)
at MulticastChatServer.main(MulticastChatServer.java:27)
/Users/Benjamin/Library/Caches/NetBeans/8.1/executor-snippets/run.xml:53: 
Java returned: 1
BUILD FAILED (total time: 0 seconds)


The code is:

import java.net.*;

public class MulticastChatServer {

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

        // Default port number we are going to use
        int portnumber = 5000;
        if (args.length >= 1) {
            portnumber = Integer.parseInt(args[0]);
        }

        // Create a MulticastSocket
        MulticastSocket serverMulticastSocket =
                new MulticastSocket(portnumber);
        System.out.println("MulticastSocket is created at port " + 
portnumber);

        // Determine the IP address of a host, given the host name
        // The host name can either be a machine name, such as "java.sun.com
",
        // or a textual representation of its IP address. If a literal IP
        // address is supplied, only the validity of the address format is 
checked.
        
        InetAddress group = InetAddress.getByName("225.4.5.6");

        // getByName- returns IP address of given host
        serverMulticastSocket.joinGroup(group);
        System.out.println("joinGroup method is called...");
        boolean infinite = true;

        // Continually receives data and prints them
        while (infinite) {
            byte buf[] = new byte[1024];
            DatagramPacket data =
                    new DatagramPacket(buf, buf.length);
            serverMulticastSocket.receive(data);
            String msg =
                    new String(data.getData()).trim();
            System.out.println("Message received from client = " + msg);
        }
        serverMulticastSocket.close();
    }
}


My network interface configuration is as follows:

Last login: Wed Sep 28 18:26:58 on ttys000

Benjamins-MacBook-Pro:~ Benjamin$ ifconfig

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384

options=3<RXCSUM,TXCSUM>

inet6 ::1 prefixlen 128 

inet 127.0.0.1 netmask 0xff000000 

inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 

nd6 options=1<PERFORMNUD>

gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280

stf0: flags=0<> mtu 1280

en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500

ether a4:5e:60:d9:ad:21 

inet6 fe80::a65e:60ff:fed9:ad21%en0 prefixlen 64 scopeid 0x4 

inet 192.168.1.10 netmask 0xffffff00 broadcast 192.168.1.255

nd6 options=1<PERFORMNUD>

media: autoselect

status: active

en1: flags=963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX> mtu 1500

options=60<TSO4,TSO6>

ether 4a:00:01:1f:c8:30 

media: autoselect <full-duplex>

status: inactive

en2: flags=963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX> mtu 1500

options=60<TSO4,TSO6>

ether 4a:00:01:1f:c8:31 

media: autoselect <full-duplex>

status: inactive

p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304

ether 06:5e:60:d9:ad:21 

media: autoselect

status: inactive

awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484

ether de:39:ac:c0:e3:7c 

inet6 fe80::dc39:acff:fec0:e37c%awdl0 prefixlen 64 scopeid 0x8 

nd6 options=1<PERFORMNUD>

media: autoselect

status: active

bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500

options=63<RXCSUM,TXCSUM,TSO4,TSO6>

ether a6:5e:60:9d:fb:00 

Configuration:

id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0

maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200

root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0

ipfilter disabled flags 0x2

member: en1 flags=3<LEARNING,DISCOVER>

        ifmaxaddr 0 port 5 priority 0 path cost 0

member: en2 flags=3<LEARNING,DISCOVER>

        ifmaxaddr 0 port 6 priority 0 path cost 0

nd6 options=1<PERFORMNUD>

media: <unknown type>

status: inactive

utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1500

inet6 fe80::935a:dea6:fc62:3b81%utun0 prefixlen 64 scopeid 0xa 

nd6 options=1<PERFORMNUD>

Benjamins-MacBook-Pro:~ Benjamin$ -Djava.net.preferIPv4Stack=true

-bash: -Djava.net.preferIPv4Stack=true: command not found

Benjamins-MacBook-Pro:~ Benjamin$ 

My basic computer info is in attachment:



-- 
You received this message because you are subscribed to the Google Groups 
"JPassion.com: Java Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/jpassion_java.
For more options, visit https://groups.google.com/d/optout.

Reply via email to