Solved

Forcefully Freeing a Socket

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
I had an issue with InstallShield not being able to use Computer Browser service on Windows Server 2012. Here is the solution I found.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

691 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