问题自己搞定。 msdn的正解:Symptoms When you attempt to set up TCP connections from ports above 5000, the local computer responds with a WSAENOBUFS (10055) error, which means: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full. ResolutionThe default maximum number of ephemeral TCP ports for Microsoft Windows NT is 5000. A new parameter has been added to Windows NT 3.51 Service Pack 5 and to Windows NT 4.0 or higher. To increase the maximum number of ephemeral ports you must set the following registry parameter: Start Registry Editor (Regedt32.exe). Locate the following key in the registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters On the Edit menu, click Add Value, and then add the following registry value: Value Name: MaxUserPort Data Type: REG_DWORD Value: 65534 <for example> Valid Range: 5000-65534 (decimal) Default: 0x1388 (5000 decimal) Description: This parameter controls the maximum port number used when an application requests any available user port from the system. Normally, ephemeral (that is, short-lived) ports are allocated between the values of 1024 and 5000 inclusive. Quit Registry Editor.
msdn的正解:Symptoms
When you attempt to set up TCP connections from ports above 5000, the local computer responds with a WSAENOBUFS (10055) error, which means: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full. ResolutionThe default maximum number of ephemeral TCP ports for Microsoft Windows NT is 5000. A new parameter has been added to Windows NT 3.51 Service Pack 5 and to Windows NT 4.0 or higher. To increase the maximum number of ephemeral ports you must set the following registry parameter: Start Registry Editor (Regedt32.exe). Locate the following key in the registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters On the Edit menu, click Add Value, and then add the following registry value: Value Name: MaxUserPort Data Type: REG_DWORD Value: 65534 <for example> Valid Range: 5000-65534 (decimal) Default: 0x1388 (5000 decimal) Description: This parameter controls the maximum port number used when an application requests any available user port from the system. Normally, ephemeral (that is, short-lived) ports are allocated between the values of 1024 and 5000 inclusive. Quit Registry Editor.
aP: PChar;//扩大缓冲区
BufSize:= 8*8192; //8k
aP:=@BufSize;
aLen := sizeof(integer);
if setsockopt(ClientSocket.Socket.SocketHandle, SOL_SOCKET,
SO_SNDBUF, aP, aLen) <> SOCKET_ERROR then
MainForm.MemoLog(‘'data sokcet add send buff succ')
else begin
Errcode := WSAGetLastError;
MainForm.MemoLog(data sokcet add send buff fail, handle:'
+ ', ErrCode: ' + inttostr(Errcode));
end; if setsockopt(ClientSocket.Socket.SocketHandle, SOL_SOCKET,
SO_RCVBUF, aP, aLen) <> SOCKET_ERROR then
MainForm.MemoLog(‘'data sokcet add receive buff succ')
else begin
Errcode := WSAGetLastError;
MainForm.MemoLog('data sokcet add receive buff fail, handle:'
+ ', ErrCode: ' + inttostr(Errcode));
end;