The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
February 2002

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

MulticastSocket problem in Windows 2000

Posted by John Isner on February 11, 2002 at 11:02 AM

I'm seeing strange behavior with MulticastSockets on a Windows 2000 machine. I'll describe the behavior giving as little detail as possible.

I have two java programs, a game and a player. The game broadcasts DatagramPackets containing "ball" information and "status" information on broadcast addresses, 230.0.0.1 and 230.0.0.2, respectively. The player starts two threads; each monitors one of the broadcast addresses:

class Player{
class BallListener implements Runnable{
public void run(){
// create socket and joinGroup 230.0.0.1
while(true){
socket.receive(packet);
...
}
}
}
class StatusListener implements Runnable{
public void run(){
// create socket and joinGroup 230.0.0.2
while(true){
socket.receive(packet);
...
}
}
}
main(String[] args){
new Thread(new StatusListener()).start(); // line 1
new Thread(new BallListener()).start(); // line 2
...

Now for the strange behavior: When I run the player, each thread receives BOTH kinds of messages. Has anybody seen this behavior?




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us