The uniqueness of socket
A normal SOCKET
number itself is unique. But the OS assigns the socket number arbitrarily, the latest closed socket number could be re-assigned to a new socket connected right next to it. So it could be that:
- A socket is assigned with a socket number 3947 (as an example) for new connection.
- The server logic reads data packets using the socket.
- The socket is closed suddenly for user closing while the server logic doesn't know about that fact.
- A different socket is assigned with the same socket number 3947, (the resurrection of that socket number).
- The server logic writes data packets to the socket, the server meets with no problem to do so. But the data packets might be sent to a different user as a result.
To prevent this troublesome situation, OIOCPNet
manages its own socket number SocketUnique
, a member of OBufferedSocket
.