|
-
Jun 27th, 2001, 11:56 AM
#1
Thread Starter
Hyperactive Member
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 :
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 ?
-
Jun 27th, 2001, 12:02 PM
#2
Lively Member
Code:
Private Sub Form_Unload()
Winsock1.Close
End
End Sub
i think not sure
-
Jun 27th, 2001, 12:34 PM
#3
Thread Starter
Hyperactive Member
That is what I did ... but it is not working
-
Jun 27th, 2001, 12:37 PM
#4
Member
it looks like your using index's. did you close all the winsocks?
-
Jun 27th, 2001, 12:41 PM
#5
Thread Starter
Hyperactive Member
Yes in fact index 0 Winsock is the only one listening to the specified port...
the others are accepting connections on other ports...
-
Jun 27th, 2001, 01:00 PM
#6
Frenzied Member
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.
-
Jun 27th, 2001, 07:33 PM
#7
Thread Starter
Hyperactive Member
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 ??
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|