Datagram socket send/receive questions
1 posts in topic
Flat View  Flat View

Posted By:   Anonymous
Posted On:   Wednesday, June 13, 2001 07:34 PM

I have an application that consists of a thread that continuously listens on a datagram socket for UDP packet. Upon receiving a packet, it processes it and then waits for the next packet. Is it sufficient to process the packets in the one receive thread or is it necessary to do the processing for each packet in a separate thread?

Also, the same application sends UDP packets. Multiple objects representing multiple clients send packets over the same datagram socket used to receive incoming packets. Is that an acceptable design?

Finally, what are the reasons and likelihood for the send() method on the datagram socket to throw an IOException?

Thanks for helping!

Re: Datagram socket send/receive questions

Posted By:   Tim_Rohaly  
Posted On:   Wednesday, June 27, 2001 12:37 PM

Read the FAQ that discusses the differences between
concurrent and iterative servers.

If you want to have multiple threads share the
same socket, you need to properly handle
concurrency issues in your code, otherwise
you will have problems.

send() can throw an IOException
if the socket is closed, if the network is down,
and probably a few other reasons as well. Sending
is done in native code, and any problems that the
native code encounter get passed back to Java
as IOExeceptions.

About | Sitemap | Contact