PRB: Winsock Control does not Fire Error Event in all Cases (244751)
The information in this article applies to:
- Microsoft Visual Basic Learning Edition for Windows 5.0
- Microsoft Visual Basic Learning Edition for Windows 6.0
- 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
This article was previously published under Q244751 SYMPTOMS
When using the Winsock Control in Visual Basic, setting the LocalPort property to a port value that is already in use on the local computer raises a Visual Basic Run-time error when the Connect or Bind method is called. The Run-time error is as follows:
'10048' - "Address in use".
Normally this could be captured using the Error Event of the Winsock Control, but even when the Error event is present for the control, the Error event is never fired and the Run-time error message box is displayed.
RESOLUTION
A valid workaround is to use Visual Basic's standard Error Handling mechanism to catch the error as illustrated in the following code snippet:
On Error Resume Next
Winsock1.Connect
If Err then
' handle the error here
End if
Simply use the On Error method around the Connect or Bind method of the Winsock Control to capture this error.
Modification Type: | Minor | Last Reviewed: | 2/11/2004 |
---|
Keywords: | kbDSWNET2003Swept kbAPI kbCtrl kbnetwork kbprb KB244751 |
---|
|