Winsock 10048 error [RESOLVED]
Hi All,
[RESOLVED: Problem was that I had another winsock control already listening on the same port numbers! Silly me!]
Firstly I apologise for the long post. I just need to get this sorted. I've been searching all night and can't seem to find an answer. I have a winsock control array on my server form, and a winsock control on my client form.
Ive written a procedure to gather all the data so i don't miss anything coming through the GetData buffer, and all seems to work well I can get data from A-B without loss, and reliably.
Until I close my client, and attempt to open and reconnect (very important to be able to do this quickly) My searching keeps bringing me back here -> http://support.microsoft.com/kb/q173619/
my code is lengthy, with all sort of junk in between, but the general settings are:
server: sckServ
.RemotePort = 4411
.LocalPort = 4511
.Listen
client: sckClient
.RemotePort = 4511
.LocalPort = 0
.Connect
this all works fine and is no problems except for when I try to reconnect I get the dreaded address in use error. MS tells me to set localport as 0.. so I change my sckServ.LocalPort to 0, no longer connects my client throws a state of '6' then shortly after switches to state '9'.. i.e doesn't connect at all. Admittably the error is no longer there.. but my app is not very usable.
I understand the workings of the TCP stack enough to know it will keep a port mapped to an app, unless its closed properly. I'm using the standard .Close method of the winsock control.. should this supplemented with anything else?
Bear in mind that at the moment this is only dealing with one of the sckServ in an array (i haven't got far enough to try that out yet), and I want to use a specific port-set so I can configure port forwding on my router and use this app from work.
A couple of suggestions that I have tried include:
http://www.vbforums.com/showthread.p...=10048+winsock
http://www.vbforums.com/showthread.p...=10048+winsock <- the API I haven't tried but i am in the process of working through it with a sample app im making specifically for this error. If anyone has tried that I'd love to know how you got on with it.
Thanks in advance for any replies, advice, suggestions etc.. I'm really stumped on this one.
Tim.
Re: Winsock 10048 error [RESOLVED]
So if I close the socket on the server side, do both sides fire a _close event?
and then I'd just say sckClient.Close under sckClient_Close and sckServer.Close under sckServer_Close event?
Not exactly.
The _Close Event is triggered whenever the other side issues the .Close command.
If the client closes his socket then the _Close Event on the server is triggered and if the server closes his socket then the _Close Event on the client is triggered.
In general, the _Close Event is triggered for either the server or the client whenever the other side closes their socket. You never call your own _Close Event; it is always triggered from the other side.