I’m using UDP for the first time and I’m wondering if there is a way to find out if a packet has arrived without calling receive on a Java 7 DatagramSocket.
I’m trying to set up my client so that it can send multiple packets to a server and after each packet sent, check to see if a response has come in from the server.
Right now I am just using the setSoTimeout method on the DatagramSocket to set the timeout to 1 milisecond, but I would rather not wait at all if it is possible.
Update:
I ended up learning about the java.nio package and was able to use that nonblocking api to do this.
I hope it’s alright to answer my own question – but I ended up learning about the java.nio package. This is a non blocking socket api.