Hello. I don't know how to force the closing of a blocked socket.
I have an server application that listens to a port. It works as it is very
simple, but I'm not sure about how to close the socket.
I use a thread to run the socket part, so I don't block the user interface.
If I close the application, and open again, the port is still in use.
I try to suspend the thread, but it doesn't work also.
How can I do that?
--
Regards,
Diego F.
brianlanning - 28 Jun 2007 14:10 GMT
> Hello. I don't know how to force the closing of a blocked socket.
>
[quoted text clipped - 7 lines]
>
> How can I do that?
When you created the thread that manages the socket, did you set the
IsBackground flag to true? If you do that, the OS will terminate your
child threads when the main application closes.
http://msdn2.microsoft.com/en-us/library/system.threading.thread.isbackground.aspx
brian
Diego F. - 28 Jun 2007 15:14 GMT
Thank you. I did that and it seems to work now.
--
Regards,
Diego F.
>> Hello. I don't know how to force the closing of a blocked socket.
>>
[quoted text clipped - 17 lines]
>
> brian
brianlanning - 28 Jun 2007 14:43 GMT
> If I close the application, and open again, the port is still in use.
Check out SO_REUSEADDR also, although that will treat the symptom, not
the disease.
brian