java - multicast receive wrong message -



java - multicast receive wrong message -

i'm working on multicastsocket. testing websphere 8.0.0.5 on aix 7. problem getting wrong message sender. testing scenario is: 1. run sendmulticast (new thread) 2. run receivemulticast (new thread) 3. run receivemulticast (new thread)

the first receiver thread receives right message. secondary receiver thread receives wrong message.

but interesting thing tried on same machine (aix 7) java 6 console application , every thing ok.

here code:

static final int port = 9999; static final string multicastaddress = "224.2.2.3"; public static void sendmulticast() { multicastsocket socket = null; datagrampacket outpacket = null; byte[] outbuf; long t= system.currenttimemillis(); //run 60 seconds long end = t+60000; seek { socket = new multicastsocket(); string msg; while(system.currenttimemillis() < end) { msg = "//172.21.131.242:51860/service_execution_cache|//172.21.131.242:51860/error_codes_cache|//172.21.131.242:51860/accounting_cache|//172.21.131.242:51860/configuration_items_cache|//172.21.131.242:51860/reference_data"; outbuf = msg.getbytes(); inetaddress address = inetaddress.getbyname(multicastaddress); outpacket = new datagrampacket(outbuf, outbuf.length, address, port); socket.settimetolive(32); socket.send(outpacket); system.out.println("server sends : " + msg); seek { thread.sleep(500); } grab (interruptedexception ie) { } } } grab (ioexception ioe) { ioe.printstacktrace(); } socket.close(); } public static void receivemulticast() { multicastsocket socket = null; datagrampacket packet = null; byte[] inbuf = new byte[1500]; long t= system.currenttimemillis(); //run 60 seconds long end = t+60000; seek { // prepare bring together multicast grouping socket = new multicastsocket(port); inetaddress address = inetaddress.getbyname(multicastaddress); socket.joingroup(address); while(system.currenttimemillis() < end) { packet = new datagrampacket(inbuf, inbuf.length); socket.receive(packet); byte[] payload = packet.getdata(); string msg = new string(payload); system.out.println("from " + packet.getaddress() + " msg : " + msg); } } grab (ioexception ioe) { ioe.printstacktrace(); } socket.close(); }

and here log: can see @ 10:39:47:675 , 10:39:48:177 missing string coming receiver.

what problem?

[2/20/13 10:39:45:162 eet] 0000003a systemout o server sends : //172.21.131.242:51860/service_execution_cache|//172.21.131.242:51860/error_codes_cache|//172.21.131.242:51860/accounting_cache|//172.21.131.242:51860/configuration_items_cache|//172.21.131.242:51860/reference_data [2/20/13 10:39:45:163 eet] 0000003b systemout o /172.21.131.242 msg : //172.21.131.242:51860/service_execution_cache|//172.21.131.242:51860/error_codes_cache|//172.21.131.242:51860/accounting_cache|//172.21.131.242:51860/configuration_items_cache|//172.21.131.242:51860/reference_data [2/20/13 10:39:45:665 eet] 0000003b systemout o /172.21.131.242 msg : //172.21.131.242:51860/service_execution_cache|//172.21.131.242:51860/error_codes_cache|//172.21.131.242:51860/accounting_cache|//172.21.131.242:51860/configuration_items_cache|//172.21.131.242:51860/reference_data [2/20/13 10:39:45:665 eet] 0000003a systemout o server sends : //172.21.131.242:51860/service_execution_cache|//172.21.131.242:51860/error_codes_cache|//172.21.131.242:51860/accounting_cache|//172.21.131.242:51860/configuration_items_cache|//172.21.131.242:51860/reference_data [2/20/13 10:39:46:167 eet] 0000003a systemout o server sends : //172.21.131.242:51860/service_execution_cache|//172.21.131.242:51860/error_codes_cache|//172.21.131.242:51860/accounting_cache|//172.21.131.242:51860/configuration_items_cache|//172.21.131.242:51860/reference_data [2/20/13 10:39:46:168 eet] 0000003b systemout o /172.21.131.242 msg : //172.21.131.242:51860/service_execution_cache|//172.21.131.242:51860/error_codes_cache|//172.21.131.242:51860/accounting_cache|//172.21.131.242:51860/configuration_items_cache|//172.21.131.242:51860/reference_data [2/20/13 10:39:46:672 eet] 0000003a systemout o server sends : //172.21.131.242:51860/service_execution_cache|//172.21.131.242:51860/error_codes_cache|//172.21.131.242:51860/accounting_cache|//172.21.131.242:51860/configuration_items_cache|//172.21.131.242:51860/reference_data [2/20/13 10:39:46:673 eet] 0000003b systemout o /172.21.131.242 msg : //172.21.131.242:51860/service_execution_cache|//172.21.131.242:51860/error_codes_cache|//172.21.131.242:51860/accounting_cache|//172.21.131.242:51860/configuration_items_cache|//172.21.131.242:51860/reference_data [2/20/13 10:39:47:173 eet] 0000003a systemout o server sends : //172.21.131.242:51860/service_execution_cache|//172.21.131.242:51860/error_codes_cache|//172.21.131.242:51860/accounting_cache|//172.21.131.242:51860/configuration_items_cache|//172.21.131.242:51860/reference_data [2/20/13 10:39:47:174 eet] 0000003b systemout o /172.21.131.242 msg : //172.21.131.242:51860/service_execution_cache|//172.21.131.242:51860/error_codes_cache|//172.21.131.242:51860/accounting_cache|//172.21.131.242:51860/configuration_items_cache|//172.21.131.242:51860/reference_data [2/20/13 10:39:47:674 eet] 0000003a systemout o server sends : //172.21.131.242:51860/service_execution_cache|//172.21.131.242:51860/error_codes_cache|//172.21.131.242:51860/accounting_cache|//172.21.131.242:51860/configuration_items_cache|//172.21.131.242:51860/reference_data [2/20/13 10:39:47:675 eet] 0000003b systemout o /46.50.52.50 msg : ce_execution_cache|//172.21.131.242:51860/error_codes_cache|//172.21.131.242:51860/accounting_cache|//172.21.131.242:51860/configuration_items_cache|//172.21.131.242:51860/reference_data131.242:51860/reference_data [2/20/13 10:39:47:676 eet] 0000003c systemout o /172.21.131.242 msg : //172.21.131.242:51860/service_execution_cache|//172.21.131.242:51860/error_codes_cache|//172.21.131.242:51860/accounting_cache|//172.21.131.242:51860/configuration_items_cache|//172.21.131.242:51860/reference_data [2/20/13 10:39:48:176 eet] 0000003a systemout o server sends : //172.21.131.242:51860/service_execution_cache|//172.21.131.242:51860/error_codes_cache|//172.21.131.242:51860/accounting_cache|//172.21.131.242:51860/configuration_items_cache|//172.21.131.242:51860/reference_data [2/20/13 10:39:48:177 eet] 0000003b systemout o /46.50.52.50 msg : ce_execution_cache|//172.21.131.242:51860/error_codes_cache|//172.21.131.242:51860/accounting_cache|//172.21.131.242:51860/configuration_items_cache|//172.21.131.242:51860/reference_data131.242:51860/reference_data

java multicast

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -