R
Rick Parrish
I have an application that accepts an existing socket connection
(passed to it by the server that actually accepted the incoming
connection), and I'm trying to find a way to have the application NOT
close the socket when it terminates.
So basically what I've done is created a class that inherits from
System.Net.Sockets.Socket. In the .NET source code I can see that the
Dispose() method closes the socket if it is still open, so my first
thought was to override the Dispose() method and leave out the socket
closing portion of the code. This failed, so maybe my understanding
of overriding isn't correct, and the base method still gets called?
Anyway, in my trial and error attempts I accidentally stumbled across
a method that works, and seems reliable on my machine, but I'd like
something I can be a little more certain of on other machines.
Basically if I call System.Threading.Thread.Sleep(2500) in my
overridden Dispose(), the connection stays open after the application
terminates.
Like I said, I have no idea if this will hold true on other machines,
which is why I'm wondering if there is an easier/better/more reliable
way to keep a Socket from being closed when an application quits?
(passed to it by the server that actually accepted the incoming
connection), and I'm trying to find a way to have the application NOT
close the socket when it terminates.
So basically what I've done is created a class that inherits from
System.Net.Sockets.Socket. In the .NET source code I can see that the
Dispose() method closes the socket if it is still open, so my first
thought was to override the Dispose() method and leave out the socket
closing portion of the code. This failed, so maybe my understanding
of overriding isn't correct, and the base method still gets called?
Anyway, in my trial and error attempts I accidentally stumbled across
a method that works, and seems reliable on my machine, but I'd like
something I can be a little more certain of on other machines.
Basically if I call System.Threading.Thread.Sleep(2500) in my
overridden Dispose(), the connection stays open after the application
terminates.
Like I said, I have no idea if this will hold true on other machines,
which is why I'm wondering if there is an easier/better/more reliable
way to keep a Socket from being closed when an application quits?