Menu

why is the port in use after end of the app?

Help
Anonymous
2001-02-05
2001-02-06
  • Anonymous

    Anonymous - 2001-02-05

    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?

     
    • Kevin Walsh

      Kevin Walsh - 2001-02-06

      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

       
    • Anonymous

      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?) ?

       
      • Kevin Walsh

        Kevin Walsh - 2001-02-06

        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.

         
        • Anonymous

          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

           

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.