First of all, with .NET, sockets are not exactly WINSOCK. Sockets are implemented in the way abstracted from OS and OS-specific APIs. That's why CLR on different OS is possible. In particular, Mono is the different implementation of CLR available on Windows and a number of other OS. For .NET, sockets API is presented via the class
System.Net.Sockets.Socket
, or, on a bit higher level and for TCP only (highly recommended in most cases), via the pair of classes:
System.Net.Sockets.TcpListener
and
System.Net.Sockets.TcpClient
:
http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.net.sockets.tcpclient.aspx[
^].
Now, about your problem. First of all, the problem is not 100% fully formulated, as we don't know what exactly you mean by "ID". Not to worry.
Please see the comments to your question. Of course, you cannot talk about "maintaining connected status" as from the very beginning you are assuming the possibility of physical disconnection. You can develop some "logical" connection which carries the semantic of the connection between the client and server (listener) part. For example, you can develop a concept of persistent client identification. You may have a mechanism of issuing and supporting of the unique client ID, but persistent one. For example, your server can provide the API for issuing of the unique ID on request. The scope of uniqueness should be just the server process, so it does not have to be world-unique (as many try to achieve using GUIDs, which would be pointless; some integer identifier would be good enough. The client can request and store the ID on client side. In case of disconnection, the client should submit stored ID instead of requesting a new one, and the server side would be able to locate the data relevant to the client using this ID. Something like that.
See also my two past answers, which are not quite relevant to your problem, but may give you some ideas:
an amateur question in socket programming[
^],
Multple clients from same port Number[
^].
—SA