SocketException is a general exception the designates a problem when trying to access or open a Socket.
So as you can imagine, solving that problem has to be done with extra care.
You shall always log the error message that accompanies the exception.
In the previous example we’ve seen the message code>Connection reset.
This happens when on of the participants “violently” closes the connection without using close().
This means that you should check whether one of the participants has terminated unexpectedly.
One slightly bizarre message can be Too many open files, especially when you run on Linux.
This message designates that to many file descriptors are open to the system.
You can avoid that error if you go to /etc/sysctl.conf and raise the number in fs.file-max field.
Additionally, you can try to give more stack memory.
Of course many other messages can be met. For example "Bind error",
where your connection cannot be established because the port cannot be bind to the socket. In that case check if the port is already in use etc.