Solved

Recycled the TCPIP socket

Posted on 1998-03-03
5
262 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 42
ODBC Connection Logging, ADO.NET 6 64
Replacement selected text 2 62
zeroFront challenge 7 99
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 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