Link to home
Start Free TrialLog in
Avatar of rlbond
rlbond

asked on

VB6: Winsock Address in use

I am making a 2-way file transfer program, with 2 winsocks, one for files and one for information. The problem is after the client connects, I invoke the close method for both, but if i try to connect again, it doesn't work. But heres the weird thing: If i step through the program, it works! But with normal F5 operation, i always get that error. Is there some way to close the port that I should know? If you need my code I can post it.
Avatar of trkcorp
trkcorp

This is common.  I have incremented the port to avoid this.  Set up a port variable and each time you open the port increment it and use that variable as port number.  You don't need a lot of numbers. Say you start with 0, Take it to say, 5, then start over at 0 again.  This has to do with the way Windows reclaims the resources involved with allocating ports.  It seems to do this when it gets around to it rather than when you close the port...
ASKER CERTIFIED SOLUTION
Avatar of PNJ
PNJ

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rlbond

ASKER

Ok that worked