Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Recycled the TCPIP socket

Posted on 1998-03-03
5
Medium Priority
?
280 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

721 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