I found out an example of using sockets. In this example, the client sends a request to the server to open the socket, and then the server (listening to a specific port) opens the socket, and everything is fine, the socket "opens" on both sides (client and server).
But it’s still not clear to me how flexible this material is. For example, is it possible for a client to close an open socket (at both ends) and open it again (provided that the server supports opening the socket).
Is it possible for the server to “know” that the socket has been closed on the client side? Is it possible for the client to know that the socket has been closed on the server side?
ADDED:
Another important thing for me. What happens if an application (without a server or client) crashes, is abnormally terminated, is killed? Is it closed for all sockets open on the side of the application?
ADDED 2:
What to do if the application on one side of the socket is disconnected (killed, closed, terminated), and then it is turned on again (on the same IP address and the same port). Should we create a new socket between the two applications, or can we use the old socket (created before the failure).
java networking sockets
Roman
source share