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...

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
Else
    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.


Thanks,
Jon

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...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.