请教高手:OnSocketErrorEvent 怎么用? 关于SOCKET的问题(90分)

  • 主题发起人 主题发起人 叶林
  • 开始时间 开始时间

叶林

Unregistered / Unconfirmed
GUEST, unregistred user!
请教高手:OnSocketErrorEvent 怎么用? 关于SOCKET的问题
 
在SOCKET出现错误时,该事件被触发,常见错误代码为:
10004 中止操作
10013 访问被拒绝
10014 地址错误
10022 参数错误
10024 SOCKET打开过多
10035 无可获取的资料
10036 一个堵塞操作进行中
10037 操作执行中
10038 在一个非法的scoket上进行操作
10039 目标地址丢失
....
可以参考一下winsock的函数WSAGetLastError()(返回最后一个winsock错误)
(在DELPHI中,可以看WINSOCK.PAS,有错误的定义)
 
The type for event handlers that respond when a Windows socket reports an error.

Unit

ScktComp

type

TErrorEvent = (eeGeneral, eeSend, eeReceive, eeConnect, eeDisconnect, eeAccept);

TSocketErrorEvent = procedure (Sender: TObject; Socket: TCustomWinSocket;
ErrorEvent: TErrorEvent; var ErrorCode: Integer) of object;

Description

The Sender parameter is the socket component that encountered the error.

The Socket parameter is the TCustomWinSocket object that receives the error notification.

The ErrorCode parameter is the error code returned by the Windows socket API
call. Changing this to 0 within an error handler prevents an exception from being raised.

The ErrorEvent parameter indicates what Socket was attempting to do when the
error occurred. It is of type TErrorEvent, which can have any of the following values:

Value Meaning

eeGeneral The socket received an error message that does not fit into
any of the following categories.
eeSend An error occurred when trying to write to the socket connection.
eeReceive An error occurred when trying to read from the socket connection.
eeConnect A connection request that was already accepted could not be completed.
eeDisconnect An error occurred when trying to close a connection.
eeAccept A problem occurred when trying to accept a client connection request.
 
后退
顶部