java - Is DatagramSocket.connect() supposed to stall when called on localhost while listening for a packet? -


in java, datagramsocket.connect(inetsocketaddress addr) supposed filter packets except port/address, when call method (while listening packet in background thread), stalls.

datagramsocket datagramsocket = new datagramsocket(8000); inetaddress localaddress = inetaddress.getbyname("localhost");//localhost/127.0.0.1 int destinationport = 7000; datagramsocket.connect(localaddress, destinationport); // stall program 

print statements before call "datagramsocket.connect" print out print statements after call "datagramsocket.connect" not.

update:

i getting stalling when calling datagramsocket.disconnect(). datagramsocket.connect, stalling happens whether specify parameters inetaddress , port , when give combined inetsocketaddress. oddity if subclass datagramsocket , call synchronized method in subclass, similar stalling results. odd thing there no other synchronized methods in entire subclass.

note java version (oracle java 8 downloaded on ubuntu):

java version "1.8.0_45" java(tm) se runtime environment (build 1.8.0_45-b14) java hotspot(tm) 64-bit server vm (build 25.45-b02, mixed mode) 

my java installation follows: http://tecadmin.net/install-oracle-java-8-jdk-8-ubuntu-via-ppa/

^ bug in java or stalling on datagramsocket.connect supposed happen? can explain behavior? ^

i have hunch:

datagramsocket.receive holds synchronized lock on datagramsocket object. when called datagramsocket.connect or datagramsocket.disconnect, methods synchronized, blocking resulted. had receive operation going around on background thread, , may explain why blocking occurred on synchronized method call introduced in subclass of datagramsocket. explanation may not correct (contingent on whether or not connect , disconnect methods synchronized on datagramsocket object), logical 1 have far.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -