在Win2000下:
var
Keepalive: tcp_keepalive;
X: DWORD;
...
Keepalive.onoff := 1;
Keepalive.KeepaliveTime := 180000; //3分钟
Keepalive.KeepaliveInterval := 30000; //30秒
WSAIoctl(ListenSocket, SIO_KEEPALIVE_VALS, @Keekalive, SizeOf(tcp_keepalive),
nil, 0, X, nil, nil);
可惜我手头上的Winsock2没有声明SIO_KEEPALIVE_VALS常量和Tcp_keepalive结构,但我看
过的那篇文章和MSDN上都有相关的描述。