procedure TForm1.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
begin
if socket.ReceiveText = 'aaaa' then
begin
xxxxxxxxxxx
end;
if socket.ReceiveText = 'bbbb' then
begin
xxxxxxxxxxx
end;end;
可能是我表达得不清楚。
我的意思是:我的程序循环向服务器发信息,如发“1”,返回"a",发“2”,返回“b”等。现在的问题是:发送后返回的不是我想要的结果。
for i:=0 to 5 do
clientsocket1.socket.SendText(inttostr(i));//发送
procedure TForm1.ClientSocket1Read(Sender: TObject;//接受
Socket: TCustomWinSocket);
begin
memo1.Lines.Add(socket.ReceiveText);
end;
procedure TForm1.ServerSocket1Read(Sender: TObject;//接受
Socket: TCustomWinSocket);
var i:integer;
ReadText:string;
begin
ReadText:=Socket.ReceiveText;
i:=StrtoInt(ReadText);
case i of
1:XXXXX;
2:XXXXX;
......
end;
end;