Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / June 2007

Tip: Looking for answers? Try searching our database.

How to close a blocked socket

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Diego F. - 28 Jun 2007 13:12 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.