Visual Basic: Winsock Control

Error Event (Winsock Control)

See Also Example Applies To

Occurs whenever an error occurs in background processing (for example, failed to connect, or failed to send or receive in the background).


object_Error(numberAs Integer, Description As String, Scode As Long, Source As String, HelpFile as String, HelpContext As Long, CancelDisplay As Boolean)

The Error event syntax has these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.
number An integer that defines the error code. See Settings below for constants.
description String containing error information.
Scode The long SCODE
Source String describing the error source.
HelpFile String containing the help file name.
HelpContext Help file context.
CancelDisplay Indicates whether to cancel the display. The default is False, which is to display the default error message box. If you do not want to use the default message box, set CancelDisplay to True.


The settings for number are:

Constant Value Description
sckOutOfMemory 7 Out of memory
sckInvalidPropertyValue 380 The property value is invalid.
sckGetNotSupported 394 The property can't be read.
sckSetNotSupported 383 The property is read-only.
sckBadState 40006 Wrong protocol or connection state for the requested transaction or request.
sckInvalidArg 40014 The argument passed to a function was not in the correct format or in the specified range.
sckSuccess 40017 Successful.
sckUnsupported 40018 Unsupported variant type.
sckInvalidOp 40020 Invalid operation at current state
sckOutOfRange 40021 Argument is out of range.
sckWrongProtocol 40026 Wrong protocol for the requested transaction or request
sckOpCanceled 1004 The operation was canceled.
sckInvalidArgument 10014 The requested address is a broadcast address, but flag is not set.
sckWouldBlock 10035 Socket is non-blocking and the specified operation will block.
sckInProgress 10036 A blocking Winsock operation in progress.
sckAlreadyComplete 10037 The operation is completed. No blocking operation in progress
sckNotSocket 10038 The descriptor is not a socket.
sckMsgTooBig 10040 The datagram is too large to fit into the buffer and is truncated.
sckPortNotSupported 10043 The specified port is not supported.
sckAddressInUse 10048 Address in use.
sckAddressNotAvailable 10049 Address not available from the local machine.
sckNetworkSubsystemFailed 10050 Network subsystem failed.
sckNetworkUnreachable 10051 The network cannot be reached from this host at this time.
sckNetReset 10052 Connection has timed out when SO_KEEPALIVE is set.
sckConnectAborted 11053 Connection is aborted due to timeout or other failure.
sckConnectionReset 10054 The connection is reset by remote side.
sckNoBufferSpace 10055 No buffer space is available.
sckAlreadyConnected 10056 Socket is already connected.
sckNotConnected 10057 Socket is not connected.
sckSocketShutdown 10058 Socket has been shut down.
sckTimedout 10060 Socket has been shut down.
sckConnectionRefused 10061 Connection is forcefully rejected.
sckNotInitialized 10093 WinsockInit should be called first.
sckHostNotFound 11001 Authoritative answer: Host not found.
sckHostNotFoundTryAgain 11002 Non-Authoritative answer: Host not found.
sckNonRecoverableError 11003 Non-recoverable errors.
sckNoData 11004 Valid name, no data record of requested type.