procedure TForm1.ServerSocketClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var
lmsg:String;
vflag,i,j:Integer;
larriveDate:TarriveDate;
ip:String;
islimit:Boolean;
resData:String;//返回数据
buff:array[0..255]of byte;
begin
ip:=Socket.RemoteAddress;
islimit:=True;
For j:=0 to ips.Count-1 Do
Begin
if (ip=ips[j]) then
begin
islimit:=False;
end;
End;
if not islimit then
Begin
CoInitialize(nil);
Socket.ReceiveBuf(buff,4);//应该就在这里修改吧
lmsg:=Socket.ReceiveText;
SendTo();
Memo1.Lines.Add(DateTimeTostr(now)+'来自主机'+ip+'的请求数据:'+lmsg );
saveToLog(DateTimeTostr(now)+'来自主机 '+ip+ ' 的请求数据:'+ lmsg);
if lmsg<>'' then
Begin
try
saveToLog(DateTimeTostr(now)+'开始处理接受数据'+lmsg);
larriveDate:=analyecmdData(lmsg);
vflag:=exChange(larriveDate);
Memo1.Lines.Add('*'+Socket.ReceiveText+'*'+lmsg);
Memo1.Lines.Add(DateTimeTostr(now)+'数据处理完毕:处理结果:'+inttostr(vflag));
saveToLog(DateTimeTostr(now)+'数据处理完毕:处理结果:'+inttostr(vflag));
except
begin
vflag:=1;
Memo1.Lines.Add(DateTimeTostr(now)+'数据处理异常:'+inttostr(vflag));
saveToLog(DateTimeTostr(now)+'数据处理异常:'+inttostr(vflag));
end;
//vflag:=1;
end;
for i:=0 to sessions do
begin //取得匹配的客户端
if session[i].CHandle = Socket.SocketHandle then
begin
case vflag of
0: resData:=inttostr(vflag)+'$'+larriveDate.userID+'$'+larriveDate.TelNo+'$'+inttostr(larriveDate.inPutKey);
1: resData:='1'+'$'+'系统繁忙请稍后冲值';
2: resData:='2'+'$'+'平台用户ID不存在';
end;