i'am writing a server-application with ccxx, but i've got a problem: when the application terminates and i try to restart it, the port is in use (for about 3 minutes). the chat-server-example has the same problem. is there a method to end the socket, so that i can restart the server whenever i want to?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You are seeing the TCP TIME_WAIT. When a port/session is abnormally closed, the os will wait a pre-detirmined time before allowing that port to be re-used. This is to help ensure that sessions are not spoofed (you wouldn't want old packets wandering around and inserting themselves into your new server process!). The timeout should be right around 3 minutes.
You can avoid this by properly closing down all the ports and sessions. Killing any network service, then trying to restart it, will display this behavior (assuming the kill is not trapped!).
Check the Unix Socket Faq for a better explanation(http://www.lcg.org/sock-faq/detail.php3?id=40
-kevin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2001-02-06
do you know how to close all the ports an sessions (are there any methods in ccxx, or how can i do it with the close()-function?) ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The Socket::endSocket() call is the one I think you are looking for. It is protected, though. Usually it is the destructor that does the cleanup and calls endSocket(). If you don't cleanly destroy all the socket objects (ctrl-c) then i don't think the destructor will ever get called.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2001-02-06
i've written a very small server (i'm a c++-newbie, too ;) would it be possible if i send you the source, you have a look at it and add this small things (shut the program down from a thread, closing the server - and the client -ports) ? i would be very greatful, because it's very important for me :)
befi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hi
i'am writing a server-application with ccxx, but i've got a problem: when the application terminates and i try to restart it, the port is in use (for about 3 minutes). the chat-server-example has the same problem. is there a method to end the socket, so that i can restart the server whenever i want to?
You are seeing the TCP TIME_WAIT. When a port/session is abnormally closed, the os will wait a pre-detirmined time before allowing that port to be re-used. This is to help ensure that sessions are not spoofed (you wouldn't want old packets wandering around and inserting themselves into your new server process!). The timeout should be right around 3 minutes.
You can avoid this by properly closing down all the ports and sessions. Killing any network service, then trying to restart it, will display this behavior (assuming the kill is not trapped!).
Check the Unix Socket Faq for a better explanation(http://www.lcg.org/sock-faq/detail.php3?id=40
-kevin
do you know how to close all the ports an sessions (are there any methods in ccxx, or how can i do it with the close()-function?) ?
The Socket::endSocket() call is the one I think you are looking for. It is protected, though. Usually it is the destructor that does the cleanup and calls endSocket(). If you don't cleanly destroy all the socket objects (ctrl-c) then i don't think the destructor will ever get called.
i've written a very small server (i'm a c++-newbie, too ;) would it be possible if i send you the source, you have a look at it and add this small things (shut the program down from a thread, closing the server - and the client -ports) ? i would be very greatful, because it's very important for me :)
befi