Problem
In a desktop network application upon sending data to DatagramSocket sometimes the exceptiption occur:
java.net.SocketException: No buffer space available (maximum connections reached?): Datagram send failed
After this exception socket is completely unusable: it doesn’t recieve anything and send() hangs indefinitely. The reproducing test is a trivial app (create socket, bind, while (true) send();)
I can repeat this behavior in 100% of cases only on Windows when my machine goes to sleep mode and then come back in a middle of “intensive data flow”.
The questions are:
- is this behavior normal for bsd sockets – to get unusable after an error? or it is a kind of WSA bug?
- is there any way to “reset” faulty socket to working state or reopening socket is the only solution?
- is it possible to distinguish such conditions from regular I/O errors (i.e. recoverable ones) after catching exception?
- are there any general guidance/advices on when I shall reopen sockets in application (I mean: network address changed, PC sleep/wake-up and other events)
Thanks! 🙂
A socket is unusable after any exception at all with the exception of SocketTimeoutException.