Server will not connect to client - Winsock Error 0?!!
I am having a problem here.
I have a server program set up to connect to its client as soon as the client connects. The client connects fine, but apparently the server listener's Connect event isn't firing, because I'm not getting a message on the client saying we're connected. I paused the program, and did a wskServerListener.State check, and it was in error. I checked what the error number was, and it says Error 0, and will not give me an error description. Take the error handler out, and I get the error "Invalid operation for current state, and wskServerListener still reports that it's in error.
This is the code that connects to the client as soon as the client connects to the server.
VB Code:
Private Sub wskServerListener_ConnectionRequest(ByVal requestID As Long)
wskServerListener.Close
wskServerListener.Accept requestID
rtbServerMessages.Text = rtbServerMessages.Text & "A client has connected" & vbNewLine
ColorServerMessageLines
If Not wskServerConnector.State = sckConnected Then
wskServerConnector.Connect wskServerListener.RemoteHostIP, 350
End If
End Sub
This is the code that handles the connection request to the client.
VB Code:
Private Sub wskClientListener_ConnectionRequest(ByVal requestID As Long)
wskClientConnector.Close
wskClientConnector.Accept requestID
End Sub
And as you can see from this code, I do have it set to listen on the correct port, 350.
VB Code:
Private Sub wskClientConnector_SendComplete()
If Not wskClientListener.State = sckListening Then
wskClientListener.LocalPort = 350
wskClientListener.Listen
End If
End Sub
Upon connection, the client sends your username to the server for identification like this.
VB Code:
Private Sub wskClientConnector_Connect()
wskClientConnector.SendData "USER " & txtUsername.Text
End Sub