Results 1 to 7 of 7

Thread: Winsock Problem

  1. #1

    Thread Starter
    Hyperactive Member razzaj's Avatar
    Join Date
    Oct 1999
    Location
    jounieh
    Posts
    261

    Winsock Problem

    I have a server Application that takes connections on Port X lets say.

    When I am terminating the Application I am executing the following code :



    Code:
     
    
    
           Winsock1(0).Close
    and I am looping waiting for the winsock to close

    WHen I try to run the application Again. It always gives me the error Port in USe....

    I have to restart for it to clear the port ... Any ideas How I can explicitely free the Port I am connecting to ?
    - regards -
    - razzaj -

  2. #2
    Lively Member Blaster's Avatar
    Join Date
    Jun 2001
    Posts
    70
    Code:
    Private Sub Form_Unload()
    Winsock1.Close
    End
    End Sub
    i think not sure

  3. #3

    Thread Starter
    Hyperactive Member razzaj's Avatar
    Join Date
    Oct 1999
    Location
    jounieh
    Posts
    261
    That is what I did ... but it is not working
    - regards -
    - razzaj -

  4. #4
    Member bizzyVB's Avatar
    Join Date
    Jun 2001
    Location
    Florida
    Posts
    38
    it looks like your using index's. did you close all the winsocks?

  5. #5

    Thread Starter
    Hyperactive Member razzaj's Avatar
    Join Date
    Oct 1999
    Location
    jounieh
    Posts
    261
    Yes in fact index 0 Winsock is the only one listening to the specified port...
    the others are accepting connections on other ports...
    - regards -
    - razzaj -

  6. #6
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177
    How soon after stopping the application do you try to restart it?

    There is a period of time that the port will be in state TIME_WAIT. The TIME_WAIT value is set to 2 times the maximum segment lifetime, which is related to the time-to-live (TTL) value of IP datagrams within the network. Simply put, this allows TCP to ensure that connections are properly closed. The side initiating the close must hang around long enough for the other side to send its final packet.

    You can check the port's state by doing a netstat from a command prompt.

  7. #7

    Thread Starter
    Hyperactive Member razzaj's Avatar
    Join Date
    Oct 1999
    Location
    jounieh
    Posts
    261
    hmmm yeah .. you are right ... i noticed that sometimes after leaving it a while before restarting it it did nt generate any errors , but I thouht that when I ask it to close it would directly close ... and by the way the winsock i am takling about is a Server winsock ( listening ) ...
    and by the way the api function Listen exists right ??
    - regards -
    - razzaj -

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