Leider konnte mir bisher keiner weiterhelfen. Darum schreibe ich hier noch einmal die überarbeitete Kurzform hin!
Das Problem besteht darin, dass ich erst gar keine Paketgröße erhalte!!! -> Variable SL beim Client bleibt 0!!!
Bitte, bitte helft mir!
Client
Delphi-Quellcode:
var
Netview: TNetview;
rSize: int64;
rec: boolean=false;
Stream: TMemoryStream;
procedure TNetview.ClientSocketRead(Sender: TObject;
Socket: TCustomWinSocket);
var
SL : Integer;
Pic: TJpegimage;
begin
Log.Lines.Add(Socket.ReceiveText);
If copy(Log.Lines[Log.Lines.Capacity-1],0,3)='#SL'
then
begin
SL := Socket.ReceiveLength;
If SL = 0 then Exit;
If Rec
then
begin
Socket.ReceiveBuf(Pointer(Int64(Stream.Memory) + Stream.Position)^, SL);
Stream.Position := Stream.Position + SL;
If Stream.Position = rSize
then
begin
Stream.Position := 0;
Pic := TJpegimage.Create;
try
Pic.LoadFromStream(Stream);
remote.Iscreen.Picture.Assign(Pic);
remote.Iscreen.Refresh;
finally
Pic.Free;
end;
Stream.Clear;
FreeAndNil(Stream);
Rec := False;
end;
end
else
begin
rSize := StrToInt(copy(Log.Lines[Log.Lines.Capacity-1],4,length(Log.Lines[Log.Lines.Capacity])));
Stream := TMemoryStream.Create;
Stream.SetSize(rSize);
Stream.Position := 0;
Rec := True;
Socket.SendText('#SCREENOK');
end;
end;
end;
Server
Delphi-Quellcode:
var
Form1: TForm1;
voice: Variant;
Stream : TMemoryStream;
JPG: TJpegImage;
procedure TForm1.ServerClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
Log.Lines.Add(Socket.ReceiveText);
If Log.Lines[Log.Lines.Capacity-1]='#SCREENSHOT'
then
begin
Stream := TMemoryStream.Create;
try
Screenshot; //Screenshot wird gemacht und in ca. 150kb großes TJPEGImage geladen
JPG.SaveToStream(Stream);
finally
JPG.Free;
end;
Socket.SendText('#SL' + inttostr(Stream.Size));
end;
If Log.Lines[Log.Lines.Capacity -1]='#SCREENOK'
then
begin
try
Socket.SendBuf(Stream, Stream.Size);
Stream.Clear;
FreeAndNil(Stream);
FreeAndNil(JPG);
except
end;
end;
end;