Search code examples
javanio

Correctly handle server.accept() exception


How should I handle a ServerSocket(Channel).accept() exception? Is this exception can be thrown by client fault? In JavaDoc says only that:

IOException - If some other I/O error occurs

Solution

  • How should I handle a ServerSocket(Channel).accept() exception?

    Close the channel. If you're supposed to be fault-tolerant, try to open a new one and continue accepting.

    Is this exception can be thrown by client fault?

    No.