Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Recycled the TCPIP socket

Posted on 1998-03-03
5
Medium Priority
?
285 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

885 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