我服务器用的是idtcpserver ,而且用了IdThreadMgrPool线程池,客户端用idtcpclient和idAntiFreeze,请高手帮下我解决很多人一起登陆的问题,我代码如下:
服务器tcpserverprocedure TForm1.itsTalkExecute(AThread: TIdPeerThread);
begin
acceptstr:=Athread.Connection.ReadLn();
PeerIP:=AThread.Connection.Socket.Binding.PeerIP;
with athread.Connection do
begin
if SameText(acceptstr,'QUIT') then
begin
memoSystemInfo.Lines.Add(DateTimeToStr(Now())+' :'+PeerIP+'退出服务器!');
updateip();
end
else  begin try
sendid:=Leftstr(acceptstr,AnsiPos(',',acceptstr)-1);//通过AnsiPos(const Substr, S: string)返回子串Substr出现在主串S中的第一个位置
memoSystemInfo.Lines.Add(DateTimeToStr(Now())+':'+AThread.Connection.Socket.Binding.PeerIP+' 发送消息给 '+sendid);//
memoTalkInfo.Lines.Add(DateTimeToStr(Now())+':'+AThread.Connection.Socket.Binding.PeerIP+' 说:'+acceptstr);//
Athread.Connection.WriteLn('发送成功!'); finally
end;
end;
end;
end;