Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Multicast chat program

843790Feb 2 2007 — edited Feb 4 2007
Hi,


The problem I am having is when checking to see if two specific users are using the chat program as I want them to have a separate multicast session. The if statements work and the client sends the message. The server just doesn't seem to relay it back to the client in either case.

The code for the client part is below:



if (userName.startsWith ("Steve") || userName.startsWith ("David"))
{
MulticastSocket socket = new MulticastSocket (4447);
InetAddress address = InetAddress.getByName ("233.0.0.13");
socket.joinGroup (address);
}
else
{
MulticastSocket socket = new MulticastSocket (4449);
InetAddress address = InetAddress.getByName ("232.0.0.13");
socket.joinGroup (address);
}

And the server part:



if (received.startsWith ("Steve") || received.startsWith ("David"))
{

InetAddress group = InetAddress.getByName ("233.0.0.13");
packet = new DatagramPacket (buf, buf.length, group, 4447);
socket.send (packet);

}
else
{
InetAddress group = InetAddress.getByName ("232.0.0.13");
packet = new DatagramPacket (buf, buf.length, group, 4449);
socket.send (packet);
}

Does anyone have any ideas??
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 4 2007
Added on Feb 2 2007
13 comments
260 views