to 张无忌:
我是用Timer临控clientsocket的状态的,程序如下:
if (clientSCK.Active=false)and(mypush.Count>0) then
begin
clientSCK.Socket.Close;
if Timer4.Interval<>LocateTime then
Application.ProcessMessages;
clientSCK.Open;
exit;
end;
EXCEPT
clientSCK.Socket.Close;
Send_Grid.Cells[2,1]:='尝试联接...';
Send_Grid.Refresh;
END;
在线程中接收程序:
SckStream1 := TwinSocketStream.Create(BIQ2002SCK.clientSCK.Socket,TimeOut*1000);
。。。。。。。。。。。。。。。。。。
SendSucc:=SckStream1.Write(pwidechar(teststr)^,length(teststr)+1);//发送
接收:
while (not Terminated) and (clientSCK.Active) do
begin
if SckStream1.WaitForData(TimeOut*1000) then
if SckStream1.Read(rec, Length(rec)+1) <> 0 then
if length(rec)>2 then
begin
。。。。。。。。。。。。。。。。。。
请帮忙阿,谢谢!!