L
Lenard Gunda
Hi,
I have the following problem when I am working with sockets in C#. I do not
remember running into the same problem some while ago, when working with
sockets from C++ (using native code, not managed).
I create a server socket, and then listen on it. I then accept a new
connection from that server socket. If I now close the server socket, it
also closes the accepted connection as well, automatically. This feels
stupid.
In C++ closing the listening socket has no effect on the accepted socket. In
fact I recall seeing some examples, which did just like this.
However, in C#, there seems to be some "mysterious" connection between the
two.
I read the documentation in MSDN Library, and tried searching for this
behaviour. I even looked at the System.Net.Sockets namespace with Reflector,
but did not come across anything usefull. Does anyone know why C# (.NET)
behaves like this, and how it could be made to behave the way classic
winsock behaves?
I would like to close the server socket after the client has connected,
because I do not want to listen any longer for new connections, just
communicate with that single client.
Thanks for any help
Lenard Gunda
I have the following problem when I am working with sockets in C#. I do not
remember running into the same problem some while ago, when working with
sockets from C++ (using native code, not managed).
I create a server socket, and then listen on it. I then accept a new
connection from that server socket. If I now close the server socket, it
also closes the accepted connection as well, automatically. This feels
stupid.
In C++ closing the listening socket has no effect on the accepted socket. In
fact I recall seeing some examples, which did just like this.
However, in C#, there seems to be some "mysterious" connection between the
two.
I read the documentation in MSDN Library, and tried searching for this
behaviour. I even looked at the System.Net.Sockets namespace with Reflector,
but did not come across anything usefull. Does anyone know why C# (.NET)
behaves like this, and how it could be made to behave the way classic
winsock behaves?
I would like to close the server socket after the client has connected,
because I do not want to listen any longer for new connections, just
communicate with that single client.
Thanks for any help
Lenard Gunda