For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > April 2005 > Winsock









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Winsock
Troy Street

2005-04-28, 3:56 am

Hi,

I'm having a bit of trouble with the Winsock control and was hoping someone
here could help me.

When I close the Winsock connection and try to reconnect anywhere from 20
seconds to 2 minutes later, I get the following message: Error 10048 Address
in use. It seems if I wait longer then 2 minutes, whatever is remaining
connected, times-out, and allows me to connect again.

The project I am working on is still in the debugging stages and requires
quite a few restarts in the VB IDE. Needless to say it's becoming a bit of
an annoyance, and I wouldn't be too crazy about having my final app work in
this manner either.

Below is my exit code. I am using VB6 SP6 on a Windows 2000 machine. Am I
missing something? Is there a KB article on Winsock bugs of this nature? (if
there is, I couldn't find it).

TIA


Private Sub mnuExit_Click()
WinSock1.Close
Unload Me
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If WinSock1.State > 1 Then Cancel = 1
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set frmMainForm = Nothing
End Sub



Bob Butler

2005-04-28, 3:56 am

"Troy Street" <street829@comcast.net> wrote in message
news:wfadnZolU6uwtu3fRVn-1g@comcast.com
> Hi,
>
> I'm having a bit of trouble with the Winsock control and was hoping
> someone here could help me.
>
> When I close the Winsock connection and try to reconnect anywhere
> from 20 seconds to 2 minutes later, I get the following message: Error

10048 Address
> in use. It seems if I wait longer then 2 minutes, whatever is
> remaining connected, times-out, and allows me to connect again.


before you reconnect try doing winsock1.localport=0

when you connect a local port number is assigned and that can't be re-used
until the tcp/ip stack has a chance to wait for straggler packets and do
it's normal cleanup processing; you can do some extra work to eliminate the
delay but unless you have to use a specific local port it's normally not
important.

--
Reply to the group so all can participate
VB.Net: "Fool me once..."

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com