Problem with DatagramSocket.receive()?

Tom Tromey tromey@cygnus.com
Sat Jul 22 17:25:00 GMT 2000


>> I am using gcj and libgcj version 2.95.1 to compile my java
>> application (SNMP agent). Inside one of my classes i use a
>> DatagramSocket to receive packets from remote hosts. I am using the
>> receive(DatagramPacket) method inside a thread in a while(true)
>> loop. My application hangs indefinitely in the receive() method.

I don't know much about java.net.  Warren is really the local expert.

>> The following is the output i got from running my application with
>> gdb:
>> Program received signal SIGPWR, Power fail/restart.

I thought SIGPWR was used as part of the Linux pthread implementation.
What version of gdb are you using?  I think you can "cont" out of this
state.

>> It appears that whenever i send a packet to the port on which the
>> socket is listening the Receive queue size keeps increasing but the
>> packet is never read by the socket ie it seems that the receive()
>> method locks inside somewhere and never returns (or is it because
>> the thread that does the receive() call is suspended and never
>> restarts?).

You can put a breakpoint on the receive method and step through it to
see what happens to the receive call.

Are you catching errors?  Maybe you are ignoring the actual error?
Or maybe you are trying to receive on the wrong socket somehow?  That
is what it sounds like to me (far away from the actual problem :-)

>> Does gcj has any problem when sockets are used inside
>> threads? (I am using a lot of threads in my application.).

As far as I know there are no problems doing this.

Tom


More information about the Java mailing list