Solved

Forcefully Freeing a Socket

Posted on 1998-09-24
4
326 Views
Last Modified: 2013-12-23
In Solaris 2.5, I'm running an Oracle web listener.
If a client somewhere is using it, I want to be able
to forcefully terminate use of the socket, free the
socket, and restart the listener.

I can kill the listener, but cannot restart it since
Solaris thinks the socket is still in use.  Even
though the listener has long since died,
issuing "netstat -a" gives:

LocalAddr     RemoteAddr   Swind Send-Q Rwind Recv-Q State
robkuo.9000  roboropc.2757  7964   0  8760   0  ESTABLISHED

How can I tell Solaris to FREE THAT SOCKET???
Many thanks!

0
Comment
Question by:stesul
  • 2
4 Comments
 
LVL 3

Expert Comment

by:zhongbing
ID: 1582361
1. there is no way in traditional unix systems to free a socket. if it preserve by the program. and if the program abort abnomally without close it corretly. it will be in close-wait for a long time. it decided the by the 3-handshake protocal of the socket connection establish and close.
2. so i think the only way is "tcp stop" .
zhong
0
 

Author Comment

by:stesul
ID: 1582362
You mention the command: "tcp stop" .
But no such command exists on my Solaris 2.5.1 system.  What system
are you referring to?  What do you do on a Solaris 2.5 system?
Thanks!
0
 

Accepted Solution

by:
ydsh earned 200 total points
ID: 1582363
Put these codes into your client program:
 
struct linger socketLinger;

        socketLinger.l_onoff = 1;
        socketLinger.l_linger = 0;
        if(setsockopt(sockfd,SOL_SOCKET,SO_LINGER,
                           &socketLinger,sizeof(struct linger)) == -1){
                perror("set sock opt error");
                return(-1);
        }      
Then you can forcefuly terminate the use of socket, and free it.
                                                               
0
 

Author Comment

by:stesul
ID: 1582364
Thanks for your answer.  It answers the question, IF I have source
for the client.  Still, it is a good answer, so I give it an A.

But if I DON'T have source for the client or server, how do I free sockets?
Is there a way?

Many thanks!

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

If your business is like most, chances are you still need to maintain a fax infrastructure for your staff. It’s hard to believe that a communication technology that was thriving in the mid-80s could still be an essential part of your team’s modern I…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

830 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