ClientSocket连接产生 错误 ErrorCode=10050,怎么解决(92分)

  • 主题发起人 主题发起人 smilboy
  • 开始时间 开始时间
S

smilboy

Unregistered / Unconfirmed
GUEST, unregistred user!
在TIMER中不停的连接服务器,如果失败就再连。
可是在WIN98中会出现错误提示,ErrorCode=10050,
我查了MSDN,是buffer益处了。

procedure TfrmClient.Connect;
begin
if not csClient.Active then
if Length(ServerIP) > 7 then
try
csClient.Address := '192.168.0.1';
csClient.Port:=12345;
csClient.Active := true;
except
csClient.Active := false;
end;
end;

处理错误的代码,可是屏蔽不住错误a
procedure TfrmClient.csClientError(Sender: TObject;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
ErrorCode := 0;
try
csClient.Active := false;
except
end;
end;
 
你贴的代码没有问题。
 
我也知道没问题
可是在98上长时间连不到服务器上后就会出现这个问题,可能是连接的缓冲益处了。,
有没方法解决呀

2000中我没发现这个问题
 
你設置的端口一直都是12345嗎﹖是否端口有問題﹖[?][blue][/blue]
 
也许是98的缺陷吧,很难解释清楚
 
你的这段代码可能有问题
procedure TfrmClient.csClientError(Sender: TObject;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
ErrorCode := 0;
try
csClient.Active := false;
except
end;
end;
你应该设置Active属性之前先判断一下Active的属性:
procedure TfrmClient.csClientError(Sender: TObject;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
ErrorCode := 0;
try
if csClient.Active then
csClient.Active := false;
except
end;
end;
 
ErrorCode := 0;
try
if csClient.Active then
csClient.Active := false;
except
end;
我觉得这个没什么必要了,不管他是什么状态,既然他出错,我就把他FALSE掉,应该不会有问题吧
我现在把时间间隔调整了一下,是10秒了,很久没出过这个问题了
 
>>ErrorCode=10050,
表示连接失败。
 
对不起是我写错了,代码是10055


Windows Sockets Error Codes, Values, and Meanings
ID: Q150537



--------------------------------------------------------------------------------
The information in this article applies to:

Microsoft Windows NT Workstation versions 3.5, 3.51
Microsoft Windows NT Server versions 3.5, 3.51
Microsoft LAN Manager version 2.2c
Microsoft TCP/IP-32 for Windows for Workgroups, versions 3.11, 3.11a, and 3.11b
Microsoft Windows 95
Microsoft Network Client version 3.0 for MS-DOS

--------------------------------------------------------------------------------


SUMMARY
This article describes the Windows Sockets error codes.



MORE INFORMATION
The following table is a list of possible error codes returned by the WSAGetLastError() call, along with their explanations.


Windows Sockets code Error Description
------------------------------------------------------------------------

WSAEINTR 10004 Interrupted system call.
WSAEBADF 10009 Bad file number.
WSEACCES 10013 Permission denied.
WSAEFAULT 10014 Bad address.
WSAEINVAL 10022 Invalid argument.
WSAEMFILE 10024 Too many open files.
WSAEWOULDBLOCK 10035 Operation would block.
WSAEINPROGRESS 10036 Operation now in progress. This error is
returned if any Windows Sockets API
function is called while a blocking
function is in progress.
WSAEALREADY 10037 Operation already in progress.
WSAENOTSOCK 10038 Socket operation on nonsocket.
WSAEDESTADDRREQ 10039 Destination address required.
WSAEMSGSIZE 10040 Message too long.
WSAEPROTOTYPE 10041 Protocol wrong type for socket.
WSAENOPROTOOPT 10042 Protocol not available.
WSAEPROTONOSUPPORT 10043 Protocol not supported.
WSAESOCKTNOSUPPORT 10044 Socket type not supported.
WSAEOPNOTSUPP 10045 Operation not supported on socket.
WSAEPFNOSUPPORT 10046 Protocol family not supported.
WSAEAFNOSUPPORT 10047 Address family not supported by protocol
family.
WSAEADDRINUSE 10048 Address already in use.
WSAEADDRNOTAVAIL 10049 Cannot assign requested address.
WSAENETDOWN 10050 Network is down. This error may be
reported at any time if the Windows
Sockets implementation detects an
underlying failure.
WSAENETUNREACH 10051 Network is unreachable.
WSAENETRESET 10052 Network dropped connection on reset.
WSAECONNABORTED 10053 Software caused connection abort.
WSAECONNRESET 10054 Connection reset by peer.
WSAENOBUFS 10055 No buffer space available.
WSAEISCONN 10056 Socket is already connected.
WSAENOTCONN 10057 Socket is not connected.
WSAESHUTDOWN 10058 Cannot send after socket shutdown.
WSAETOOMANYREFS 10059 Too many references: cannot splice.
WSAETIMEDOUT 10060 Connection timed out.
WSAECONNREFUSED 10061 Connection refused.
WSAELOOP 10062 Too many levels of symbolic links.
WSAENAMETOOLONG 10063 File name too long.
WSAEHOSTDOWN 10064 Host is down.
WSAEHOSTUNREACH 10065 No route to host.
WSASYSNOTREADY 10091 Returned by WSAStartup(), indicating that
the network subsystem is unusable.
WSAVERNOTSUPPORTED 10092 Returned by WSAStartup(), indicating that
the Windows Sockets DLL cannot support
this application.
WSANOTINITIALISED 10093 Winsock not initialized. This message is
returned by any function except
WSAStartup(), indicating that a
successful WSAStartup() has not yet been
performed.
WSAEDISCON 10101 Disconnect.
WSAHOST_NOT_FOUND 11001 Host not found. This message indicates
that the key (name, address, and so on)
was not found.
WSATRY_AGAIN 11002 Nonauthoritative host not found. This
error may suggest that the name service
itself is not functioning.
WSANO_RECOVERY 11003 Nonrecoverable error. This error may
suggest that the name service itself is
not functioning.
WSANO_DATA 11004 Valid name, no data record of requested
type. This error indicates that the key
(name, address, and so on) was not found.
NOTE: This table does not include all of the error codes defined in Winsock.h.

Additional query words: networking

Keywords : kberrmsg kbnetwork kbAPI kbSDKPlatform kbWinsock wfwg nttcp kbGrpNet
Version : WINDOWS:2.20 3.00 3.11 3.50 3.51
Platform : WINDOWS
Issue type : kbinfo


Last Reviewed: September 23, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.




--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources.
 
连接前先关闭timer
失败后再把timer打开
否则就可能出现这种问题
 
接受答案了.
 
后退
顶部