Registriert seit: 7. Aug 2008
Ort: Brandenburg
1.477 Beiträge
Delphi 12 Athens
|
AW: Suche die TByteBuffer Klasse aus SysUtils ab XE 3 (?)
18. Okt 2013, 13:36
Einfach durch TMemoryStream ersetzen (ungetestet):
Delphi-Quellcode:
function SendRequest(var AData: string): boolean;
var
len: integer;
bytes: TBytes;
temp_buffer: TByteArray;
buffer: TMemoryStream;
begin
Result := false;
if AData <> '' then
begin
// FClient = ScktComp.TClientSocket;
if FClient.Active then
begin
len := Length(AData);
SetLength(bytes,Length(AData));
bytes := BytesOf(AData);
if FClient.Socket.SendBuf(bytes[0],Length(bytes)) = len then
begin
buffer := TMemoryStream.Create;
try
if not WaitForResponse(FClient.Socket,1) then
begin
len := FClient.Socket.ReceiveLength;
// Nutzdaten übernehmen und zurückgeben
if not WaitForResponse(FClient.Socket,len) then
begin
ZeroMemory(@temp_buffer,SizeOf(temp_buffer));
AData := '';
repeat
len := FClient.Socket.ReceiveLength;
if FClient.Socket.ReceiveBuf(temp_buffer,len) > 0 then
begin
buffer.WriteBuffer(temp_buffer[0],len);
ZeroMemory(@temp_buffer,SizeOf(temp_buffer));
Delay(1);
end;
until (len = 0);
ZeroMemory(@bytes,SizeOf(bytes));
SetLength(bytes,buffer.Size);
CopyMemory(@bytes[0],buffer.Memory,buffer.Size);
AData := AData + TEncoding.Unicode.GetString(bytes);
if AData <> '' then
begin
// In AData steht die Antwort
Result := true;
end;
end;
end;
finally
buffer.Free;
Screen.Cursor := crDefault;
end;
end;
end;
end;
end;
|
|
Zitat
|