PDA

Click to See Complete Forum and Search --> : Please help me with this very simple winsock problem!!


thejoker
Apr 3rd, 2005, 12:12 PM
Hi,

I need to build a very simple application. What is required to test both the client and server applications on the same PC? I am running Windows XP with Visual Basic 6 SP 6.

The code for the simple client and server programs is as follows, but for some reason I get the error: runtime error 40006: wrong protocol or connection state for the requested transaction or request.

The code:

The Server app:

Private Sub Form_Load()
Winsock1.LocalPort = 1000
Form1.Caption = Winsock1.LocalIP
Winsock1.Listen


End Sub

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> sckClosed Then
Winsock1.Close
Winsock.Accept requestID
End If
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)


Winsock1.GetData strData, vbString
Form1.Print strData

End Sub

The client app:

Private Sub cmdSendhello_Click()


Winsock1.SendData "hello"




End Sub

Private Sub Command1_Click()
Winsock1.RemotePort = 1000
Winsock1.RemoteHost = "192.168.1.3"

Winsock1.Connect
End Sub

thejoker
Apr 3rd, 2005, 12:34 PM
no need, i figured it, I replaced the IP with the machine name and it worked

wiccaan
Apr 3rd, 2005, 12:56 PM
If your testing it on the same computer, you can use your loopback IP which is 127.0.0.1 as the remote host.

chemicalNova
Apr 3rd, 2005, 09:24 PM
Or just:

.RemoteHost = localhost

:)

Phreak