troubleshooting Question

Keeping the Visual Basic 6 Winsock control connection open after the client closes connection

Avatar of pdamedic
pdamedic asked on
Visual Basic Classic
9 Comments1 Solution1008 ViewsLast Modified:
I have a PDA unit that connects wirelessly to a PC running my visual basic program with the winsock control. I pass it data to query a database then it returns the data to the PDA. It works fine. The problem is after the PDA goes into sleep mode and the connection is dropped my VB6 program gives an Error 40020 when trying to reconnect. If anyone has some sample code that would be a big help.

Private Sub Form_Load()
    Load wsServer(1)
    txtIP = wsServer(0).LocalIP
    txtName = wsServer(0).LocalHostName
    txtPort = wsServer(0).LocalPort
End Sub

Private Sub wsServer_Close(index As Integer)
    lbStatus.AddItem ("Closed at " + Str(Time))
End Sub

Private Sub wsServer_ConnectionRequest(index As Integer, ByVal requestID As Long)
    On Error GoTo Errorlbl
    If index = 0 Then
        wsServer(1).LocalPort = 0
        wsServer(1).Accept requestID
        lbStatus.AddItem "Connected " + wsServer(1).RemoteHostIP + " at " + Str(Time)
    End If
    Exit Sub
    lbStatus.AddItem "Error in Connection Request"
End Sub

Private Sub wsServer_DataArrival(index As Integer, ByVal bytesTotal As Long)

On Error GoTo ErrRec

    wsServer(index).GetData sSQLData
    wsServer(index).SendData sSQLData
Exit Sub
End Sub

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros