Solved

Recycled the TCPIP socket

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 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

12 Experts available now in Live!

Get 1:1 Help Now