| Author |
Message |
|
|
Post subject: Can I force a socket to close in CLOSE_WAIT state?
Posted: Jan 24, 2008 - 08:03 PM
|
|
New Member
Joined: Jul 18, 2007
Posts: 3
|
|
I'm troubleshooting some processes that communicate via sockets over our network. One process listens on port 2045. When the process fails (for an unkown reason at this point), I am unable to relaunch the process as I get an error, "binding stream socket:: Address already in use" and
"Error opening socket". When I run a netstat there are 6 tcp connections using port 2045 all in CLOSE_WAIT state. When everything is working fine, there is just 1 connection on that port and is in the ESTABLISHED state. Is there a way I can force those connections to close so I can relaunch the process much quicker? Is there a way to check them all in the code before I try and listen on that port? Will that mess up the other process on the other end of the socket? Thanks! |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: Can I force a socket to close in CLOSE_WAIT state?
Posted: Jan 24, 2008 - 09:59 PM
|
|
QNX Master
Joined: Sep 01, 2002
Posts: 2667
|
|
This is a common TCP/IP situation. Look it up on www.qnx.com, this has been answered numerous time.
Here is a clue for you SO_REUSEADDR and SO_REUSEPORT |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: Can I force a socket to close in CLOSE_WAIT state?
Posted: Feb 21, 2008 - 12:56 PM
|
|
New Member
Joined: Dec 12, 2007
Posts: 7
|
|
Do you need to run it for a specific address/port?
I run it like this:
int sockL;
int r = 1;
sockL = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
setsockopt(sockL, SOL_SOCKET, SO_REUSEADDR, &r, sizeof(r));
setsockopt(sockL, SOL_SOCKET, SO_REUSEPORT, &r, sizeof(r));
and I still get the same problem. |
|
|
| |
|
|
|
 |
|
|
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group Credits |
|
|