Reputation: 5072
Imagine the following scenario in UDP packets:
Now, I'm interested to what happens with the server if the second answer is received before the server is finished processing the first answer.
On the one hand, UDP is by design unreliable, and since I haven't called datagramSocket.receive(myPacket)
for the second time, I assume the second answer will be silently discarded.
On the other hand, the socket is still open, so maybe Java (or even a lower level, like in the kernel network stack) will queue the packet.
What would really happen in this case?
Upvotes: 1
Views: 307
Reputation: 30250
The OS's network stack buffers the Datagram.
As long as the socket remains open, additional calls to .receive()
will fetch the datagram contents.
If the socket is closed while packets are buffered, then they're silently discarded.
Upvotes: 3