0

hello I'm writing a program using winsock..whenever i try to send some data from the client i get the following error
"Run-time error '40006' Wrong protocol or connection state for the requesting transaction or request"
please help me in finding what's going wrong...my client code is given below

Private Sub cmdLogin_Click()
    Dim ip, port As String
    ip = "127.0.0.1"
    port = "5500"
    
    sockClient.RemoteHost = ip
    sockClient.RemotePort = port
    sockClient.Connect
    
    Dim temp As String
    temp = "HELLO WORLD"
    sockClient.SendData temp
End Sub
2
Contributors
2
Replies
8
Views
5 Years
Discussion Span
Last Post by cool_zephyr
1

If you put a watch on the sockClient control when you execute, you'll notice that the State property is 6 (Connecting). You have to throw in a DoEvents statement so the Connect event can occur. After that, you should be good to go.

Here's the code:

Private Sub cmdLogin_Click()
Dim ip, port As String
ip = "127.0.0.1"
port = "5500"
Me.sockClient.RemoteHost = ip
Me.sockClient.RemotePort = port
Me.sockClient.Connect

DoEvents

Dim temp As String
temp = "HELLO WORLD"
Me.sockClient.SendData temp

End Sub

Hope this helps!

Edited by BitBlt: n/a

Votes + Comments
agree
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.