Solved

Forcefully Freeing a Socket

Posted on 1998-09-24
4
302 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The DSL Parameters part of this article is valid and can be considered with any brand of internet router and modem (Dlink, 3com, Alcatel, Usrobotics, Parks), by accessing the configuration interface available by the manufacturer eg: http://10.1.1.1 …
#Citrix #Citrix Netscaler #HTTP Compression #Load Balance
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
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…

707 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

17 Experts available now in Live!

Get 1:1 Help Now