Solved

Forcefully Freeing a Socket

Posted on 1998-09-24
4
336 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
[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
  • 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Even if you have implemented a Mobile Device Management solution company wide, it is a good idea to make sure you are taking into account all of the major risks to your electronic protected health information (ePHI).
Don’t let your business fall victim to the coming apocalypse – use our Survival Guide for the Fax Apocalypse to identify the risks and signs of zombie fax activities at your business.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
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…

738 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