In the Socket message, when the server accepts the connection, it returns a value that is always greater than 0 if the connection is successful.
ConnectedSocket = accept(sock_desc, (struct sockaddr *)&echoClntAddr,(socklen_t*)&clntSock);
Consider the client connected to the server and the server with the assigned number 1. Then the client disconnects, and after a while another client connects. Will the accept function assign it number 1 or number 2?
If the accept function assigns number 2, then after how many connections will number 1 be assigned again?
source
share