versuchs doch mal so...
clientseitig (FTCPConnection: TIdTCPClient)
Delphi-Quellcode:
with FTCPConnection do
begin
//Daten an Server übermitteln
xSendStream := TStringStream.Create(xDataString);
try
OpenWriteBuffer;
try
WriteStream(xSendStream, true, true);
finally
CloseWriteBuffer;
end;
finally
xSendStream.Free;
end;
//Antwort von Server auslesen
xReadStream := TStringStream.Create('');
try
xSize := ReadInteger;
ReadStream(xReadStream, xSize, true);
xReadStream.Seek(0, soFromBeginning);
AReceiveVariant := xReadStream.DataString;
finally
xReadStream.Free;
end;
end;
serverseitig:
Delphi-Quellcode:
{ TMainFormTCP.OnTCPServerClientExecute:
-------------------------------------------------------------------------------}
procedure TMainFormTCP.OnTCPServerClientExecute(AThread: TIdPeerThread);
var
xReadString : Variant;
xSendStream : TStringStream;
xStringStream : TStringStream;
xSize : integer;
begin
with AThread.Connection do
begin
try
//Antwort von Client auslesen
xStringStream := TStringStream.Create('');
try
xSize := ReadInteger;
ReadStream(xStringStream, xSize);
xReadString := xStringStream.DataString;
finally
xStringStream.Free;
end;
if (xReadString <> '') then
begin
//etwas anstellen mit xReadString
//Resultat an Client übermitteln
xSendStream := TStringStream.Create(xReadString);
try
OpenWriteBuffer;
try
WriteStream(xSendStream, true, true);
finally
CloseWriteBuffer;
end;
finally
xSendStream.Free;
end;
end;
finally
Disconnect;
end;
end;
end;
hoffe du kannst davon was gebrauchen?