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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.