OpenQNX :: The QNX Community Portal

May 13, 2008 - 12:45 PM
Google
  Web openqnx.com   
     Create an account Home · Submit News · QNX Forums · QNX Download · Search   
_
Main Menu
Who's Online
There are 57 unlogged users and 2 registered users online.

You can log-in or register for a user account here.

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
functor
Post subject: Can I force a socket to close in CLOSE_WAIT state?  PostPosted: 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!
 
 View user's profile Send private message  
Reply with quote Back to top
mario
Post subject: RE: Can I force a socket to close in CLOSE_WAIT state?  PostPosted: 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
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
solvarg
Post subject: RE: Can I force a socket to close in CLOSE_WAIT state?  PostPosted: 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.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
All logos and trademarks in this site are property of their respective owners. The comments are property of their posters.
Powered by OpenQNX: The QNX Community Portal Site
QNX and the QNX logo are registered trademarks of QNX Software Systems.