BUG: Winsock Control run-time error 10054 in DataArrival event for UDP (260018)
The information in this article applies to:
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
- the operating system: Microsoft Windows 2000
This article was previously published under Q260018 SYMPTOMS
A run-time error occurs when you use network communications on a Windows 2000-based computer with a Winsock Control that uses User Datagram Protocol (UDP), and the Protocol property of the control is set as sckUDPProtocol.
If a SendData request is sent to a RemoteHost that is not listening on the RemotePort, the DataArrival event fires and indicates that 1 byte of data is available. When you call the GetData method to retrieve that data, the following Microsoft Visual Basic run-time error occurs:
'10054' - "The connection is reset by remote side".
Normally, you can capture the error by using the Error event of the Winsock Control. However, even when the Error event is present for the control, the Error event never fires and a run-time error message box displays.
CAUSE
When a UDP packet is sent to a remote computer and that computer is not listening on the port specified, the Internet Control Message Protocol (ICMP) reports this as an ICMP Port Unreachable error, which is then translated to the Windows 2000 Winsock control as error 10054.
The Winsock Control incorrectly handles the error, causing it to pass to the Visual Basic run-time where the error is subsequently caught and displayed.
RESOLUTION
To work around this problem, use the Microsoft Visual Basic Standard Error Handling mechanism to catch the error. This workaround is illustrated in the following code snippet:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim szData As String
On Error Resume Next
Winsock1.GetData szData
If Err Then
' handle the error here
End if
End Sub
Use the On Error method around the GetData method of the Winsock Control to capture the error.
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.REFERENCES
For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
245442
Winsock ignores ICMP Port Unreachable control messages
244751 Winsock Control does not fire Error Event in all cases
263823 WinSock Recvfrom() now returns WSAECONNRESET instead of blocking or timing out
Modification Type: | Major | Last Reviewed: | 5/20/2005 |
---|
Keywords: | kbDSWNET2003Swept kbAPI kbbug kbCtrl kbIP kbnetwork kbpending kbWinsock KB260018 |
---|
|