CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2005
    Posts
    1

    How can I make a PERFECT RE-USABLE SOCKET ?

    I have some problems to make a network component.

    It is a "TIME_WAIT" state on client socket.

    When the socket is in "TIME_WAIT" state, it cannot connect into any remote server.

    How can I avoid "TIME_WAIT" state?

    Or, is there any function that can check a socket in "TIME_WAIT" or not ?



    I disconnect all sessions using "DisconnectEx" function for re-using socket.

    And, all sockets are pre-binded.

    There are no problem when I disconnect client from server.

    But, client disconnects itself and then socket falls in "TIME_WAIT" state.

    I tryed to remove that state, but I can't. (failed..all)

    I applied handshaking routine, LINGER option and changing into blocking mode..

    As you know, TIME_WAIT state's duration is so~~~~ long!!

    So, I want to know, how to check it or avoid it. ( TIME_WAIT state )



    --
    ( NOVICE )
    Student~
    Seoul. Korea.

  2. #2
    Join Date
    Feb 2003
    Location
    Bangalore, India
    Posts
    1,354

    Re: How can I make a PERFECT RE-USABLE SOCKET ?

    For binding a socket which in "TIME_WAIT" state, you can use SO_REUSEADDR socket option.
    Even if our suggestions didn't help, please post the answer once you find it. We took the effort to help you, please return it to others.

    * While posting code sections please use CODE tags
    * Please check the codeguru FAQ and do a little search to see if your question have been answered before.
    * Like a post, Rate The Post
    * I blog: Network programming, Bible

    I do all things thru CHRIST who strengthens me

  3. #3
    Join Date
    May 2001
    Location
    Germany
    Posts
    1,158

    Re: How can I make a PERFECT RE-USABLE SOCKET ?

    Are you talking about a 'client'? A client does not need to bind to a specific port, so setting it to 0 would let the OS choose a free port. Normally, only servers need to bind a port, in which case Mathew's post applies.

  4. #4
    Join Date
    Feb 2003
    Location
    Bangalore, India
    Posts
    1,354

    Re: How can I make a PERFECT RE-USABLE SOCKET ?

    Sorry my last post is incorrect. Sockets that are in TIME_WAIT state cannot be reused. I was thinking of using other sockets at that time.
    Even if our suggestions didn't help, please post the answer once you find it. We took the effort to help you, please return it to others.

    * While posting code sections please use CODE tags
    * Please check the codeguru FAQ and do a little search to see if your question have been answered before.
    * Like a post, Rate The Post
    * I blog: Network programming, Bible

    I do all things thru CHRIST who strengthens me

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured