PRB: SendData Method Generates Error 40006 (183987)
The information in this article applies to:
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
This article was previously published under Q183987 SYMPTOMS
If you call the SendData method in the WinSock control before the socket
has been connected, you will receive the Microsoft Visual Basic Error:
Run-time error: 40006
"Wrong protocol or connection state for the requested transaction or
request."
CAUSE
The code is trying to call the SendData method before the port has actually
been connected. The Connect method in Visual Basic is asynchronous and is
more like a request to connect to the Winsock port.
RESOLUTION
The code must wait until the Connect event is fired before attempting to
call the SendData or GetData methods. The Connect event is a signal that
the connect request has been accepted and the connection is established.
STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 10/28/2003 |
---|
Keywords: | kbAPI kberrmsg kbnetwork kbprb kbWinsock KB183987 |
---|
|