Solved

Recycled the TCPIP socket

Posted on 1998-03-03
5
259 Views
Last Modified: 2013-11-20
How to get back the socket handle ? When I use the closesocket, the handle are not returned to the system, so i can't reuse the same socket. After a while, i need to reboot my system to get the socket handle back.
Any suggestions ?
0
Comment
Question by:kharandir
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:jtwine100697
ID: 1316709
  Not quite sure I understand, but are you RUNNING OUT of socket handles (descriptor)?  Just because the next handle you get does not equal the same value as an earlier handle does not mean that the socket was not returned to the system!

   In fact, I believe it is SUPPOSED to work like that, so that you can find when/where you are referencing a previously released socket descriptor.

-=- James.
0
 

Author Comment

by:kharandir
ID: 1316710
In fact the system runs out of handle because the closesocket() dont give the handle back to the system and so i need to reboot to get the handles back. When I use Performance Monitor and watch the handle count, it always increase. So, how to get back these handles without rebooting ? How to close a socket ?
0
 
LVL 4

Accepted Solution

by:
jtwine100697 earned 50 total points
ID: 1316711
  When you say "running out" do you mean that you keep watching the handle count increase, or are you *actually* getting INVALID_SOCKET returned from socket(...), and WSAGetLastError() is returning WSAEMFILE?

   Are you SURE that you are passing the descriptor (returned by socket(...)) to closesocket(...)?
 
   (Also try using the SO_DONTLINGER option.)

-=- James.
0
 

Author Comment

by:kharandir
ID: 1316712
I'm not receiving INVALID_SOCKET 'cause my application still works fine.
What is SO_DONTLINGER option ? How do you use it ? Can you send me an example ?
email : rikelynck@opns.be

Thanks
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 1316713
  If you are not getting INVALID_SOCKET back, then you are not "running out of sockets".

   The SO_DONTLINGER socket option makes the system close the socket right when you call closesocket(...).

   Check the docs for setsockopt(...).

-=- James.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now