hi guyzz... i have a code here about chatting using winsock, but it is not working and I tried 2 surf in net but the error cant be solvd cleared..

.i have a runtime error 40006(wrong protocol or connection state....)
and the error is refer to the senddata properties...

plzz somebody help...

8 Years
Discussion Span
Last Post by jaasaria

Hi jaasaria,

That error is usually because the connection is not active when you're trying to send the data through.

Best thing to do is to check the Winsock connection is active before sending.

If sockMain.State = sckConnected Then
    sockMain.SendData txtMessage.Text
    MsgBox "Connection Not Active!", vbCritical + vbOKOnly, "Error In Connection"
End If
End Sub

This code will check the Winsock control is connected, and send the message if it is. If the connection is not active, it will pop up an error message.

For info, my Winsock control on the form is named sockMain.



thx dude.... i got it right....

by the way, i notice that winsock was not really good component... im i correct?? sometime it is working but their a case that not.

i use only localhost for my connection but their a chance that will not be connected...

thxx for the comment and really appreciated...

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.