呼叫fhli,看到请回答(1分)

  • 主题发起人 主题发起人 多多帮助
  • 开始时间 开始时间

多多帮助

Unregistered / Unconfirmed
GUEST, unregistred user!
http://www.delphibbs.com/delphibbs/dispq.asp?lid=3894397
不小心结贴了.还有问题没问完.谢谢
能说详细点吗?
谢了
 
有人说说TCP Keepalive Timer(存活定时器)怎么用吗
 
我想你可能需要delphi代码:
TWSAIoctl = function (s: TSocket;
cmd: DWORD;lpInBuffer: PCHAR;
dwInBufferLen:DWORD;lpOutBuffer: PCHAR;
dwOutBufferLen: DWORD;
lpdwOutBytesReturned: LPDWORD;lpOverLapped: POINTER;
lpOverLappedRoutine: POINTER): Integer;
stdcall;
定义
tcp_keepalive = record
onoff: Integer;
keepalivetime: Integer;
keepaliveinterval: Integer;
end;
TTCP_KEEPALIVE = tcp_keepalive;
PTCP_KEEPALIVE = ^tcp_keepalive;
FWSAIoctl: TWSAIoctl;
inKeepAlive,OutKeepAlive:TTCP_KEEPALIVE;
procedure TfrmMain.LoadWs2_32dll;
begin
Fhand_dll := LoadLibrary('ws2_32.dll');
if (Fhand_dll <> 0) then
begin
@FWSAIoctl := GetProcAddress(Fhand_dll, 'WSAIoctl');
end;
end;
procedure TfrmMain.FreeWs2_32dll;
begin
if Fhand_dll <> 0 then
FreeLibrary(Fhand_dll);
end;

在服务端接收socket连接后
inKeepAlive.onoff:=1;
//设置3秒钟时间间隔
inKeepAlive.keepalivetime:=3000;
//开始首次KeepAlive探测前的TCP空闭时间
//设置每3秒中发送1次的心跳
inKeepAlive.keepaliveinterval:=1;
//两次KeepAlive探测间的时间间隔
insize:=sizeof(TTCP_KEEPALIVE);
outsize:=sizeof(TTCP_KEEPALIVE);
fWSAIoctl(sktGciSendSocket, SIO_KEEPALIVE_VALS, @inKeepAlive, SizeOf(tcp_keepalive),
nil, 0, @t, nil, nil);
代码你自己组织一下
 
const
IOC_IN =$80000000;
IOC_VENDOR =$18000000;
IOC_out =$40000000;
SIO_KEEPALIVE_VALS =IOC_IN or IOC_VENDOR or 4;
TCP_NODELAY = $01; //do
n't delay send to coalesce packets
TCP_MAXSEG = $02; // Set maximum segment size */
TCP_CORK = $03; // Control sending of partial frames */
TCP_KEEPIDLE = $04; // Start keeplives after this period */
TCP_KEEPINTVL = $05; // Interval between keepalives */
TCP_KEEPCNT = $06; // Number of keepalives before death */
 
很抱歉.我是菜鸟呀.看不太懂.有没有例子?谢谢
 
谁来帮我组织下代码,谢谢.
 
没人帮帮我吗.在哪里加入心跳包的代码啊
 
呼叫fhli,看到请回答 ( 积分:1, 回复:6, 阅读:77 )
本想浪费点时间帮帮你 可惜看看根本没什么价值。1个积分。你比大地震都猛。
 
上次本想给你们各50分,没想到。结错了,呵呵。正想找你呢
帮帮我吧。过过我有分了,都给你~
 
TTCP_KEEPALIVE,找不到这个定义啊.需要uses什么吗.谢谢
 
我现在用的是套接字服务器。MIDAS的ScktSrvr和TSocketConnection
 
对Socket api不熟悉的话 说也白说。
 
算了,自己研究吧.呵呵
 

Similar threads

D
回复
0
查看
707
DelphiTeacher的专栏
D
D
回复
0
查看
757
DelphiTeacher的专栏
D
D
回复
0
查看
810
DelphiTeacher的专栏
D
后退
顶部