to youngSun:
但我要把:发出去的数据但没有收到的数据回写入数据,即回写成超时,
程序:
thread1.FreeOnTerminate := TRUE;
thread1.Resume;
SckStream := TwinSocketStream.Create(BIQ2002SCK.clientSCK.Socket,TimeOut);
recTime :=0;
sckstream.
with BIQ2002SCK do
begin //
Buf_Length := 2*Length(send_bag1^) +1;
fun_type:=copy(send_bag1^,4,2);
fun_bankID := copy(send_bag1^,6,16);
fun_date := copy(send_bag1^,22,8);
fun_Time := copy(send_bag1^,30,6);
//////////////////////////////////////////////////////发送过程
label9.Font.Color:=$00FF0000;
for p:=0 to repeatTimes do
begin
try
teststr :=send_bag1^;
SendSucc:=SckStream.Write(pwidechar(teststr)^,length(teststr)+1);
except
showmessage('error');
clientSCK.Close;
SCKStream.Free;
end;
if SendSucc>0 then
begin
sendCount_tab.Text :=inttostr(strtoint(sendCount_tab.Text)+1);
repeat // and(runFlag = 'free')
if (updatelibflag = 'free')and(runFlag = 'free') then
begin
updatelibflag:='busy'; runFlag:='busy';
updateLIB(fun_type,fun_bankID);
end;
until updateLibFlag='free';
if fun_type='KF' then //insert : grid...
BagType:= '收费';
if fun_type='FK' then
BagType:= '退费';
if fun_type='CZ' then
BagType:='冲正';
if fun_type='ZZ'then
BagType:='对总帐';
if fun_type='DZ'then
BagType:='对明细';
sendStatus := '成功';
jelsID:=fun_bankid; //交易流水号
JEDATE:=copy(fun_date,1,4)+'-'+copy(fun_date,5,2)+'-'+copy(fun_date,7,8); //交易日期
JETIME:=copy(fun_time,1,2)+':'+copy(fun_time,3,2)+':'+copy(fun_time,5,2); //交易时间
send_State:='1';
insert_grid_bag(''); //插入表格;
send_State:='0';
break; //发送成功退出循环
end; //end: if....
end; //end : for...
////////////////////////////////////////////////////////////接收过程
new(recBuf);
FillChar(rec, 1024, 0);
while (not Terminated) and (clientSCK.Active) do
begin
try
recTime:=recTime+1000;
if recTime>=TimeOut*1000 then break; //进入超时控制
if SCKStream.WaitForData(1000) then
if SCKStream.Read(rec, Length(rec)+1) = 0 then
begin
recTime:=recTime+1000;
break;
end
else if length(rec)>2 then
begin