Autor Beitrag
Fighter#1
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: Di 05.12.06 14:55 
Hallo, hab da mal ne Frage
Ich versende, wie in der Library beschrieben eine Datei (ein Bild 46 Kbyte) über die Sockets, nur wann weiß ich ob das Bild da ist, bzw. wann ich es öffnen kann?
Wenn ich einfach unter den OnRead Code das Bild öffne bekomm ich ne Fehlermeldung, dass die Datei noch benutzt wird

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 05.12.06 14:59 
Moin!

user profile iconFighter#1 hat folgendes geschrieben:
Ich versende, wie in der Library beschrieben eine Datei (ein Bild 46 Kbyte) über die Sockets,

Gib mal einen exakten Link, WAS du mit "aus der Library" meinst, oder zeig mal deinen Code. ;)

user profile iconFighter#1 hat folgendes geschrieben:
nur wann weiß ich ob das Bild da ist, bzw. wann ich es öffnen kann?
Wenn ich einfach unter den OnRead Code das Bild öffne bekomm ich ne Fehlermeldung, dass die Datei noch benutzt wird

Das ist klar, es wird ja sicher nicht in einem Block empfangen.

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Fighter#1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: Di 05.12.06 15:06 
Ok, wie immer gings ja rasend schnell :-D
Und nun mein COde
ausblenden Klient (sender)
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure TForm1.bildSocketConnect(Sender: TObject; Socket: TCustomWinSocket);
var
  scr:TBitmap;
  FStream: TFileStream;
begin
  scr:=TBitmap.Create;
  //Screenshot machen
  MakeScreenshot(scr);
  //Screenshot speichern
  scr.SaveToFile(ExtractFilePath(paramstr(0))+'\scr.bmp');
  //Als Jpeg
  BmpToJpg(ExtractFilePath(paramstr(0))+'\scr.bmp',1);
  //In den Stream einbinden
  FStream := TFileStream.Create(ExtractFilePath(paramstr(0))+'\scr.jpg', fmOpenRead);
  //und verschicken
  Socket.SendStream(FStream);
  //Dannn Socket deaktivieren, womit im Server bild geladen wird ...
  bildSocket.Active:=False;
  //Bitmal löschen
  DeleteFile(ExtractFilePath(paramstr(0))+'\scr.bmp');
end;


ausblenden Server (empfänger)
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
//Die Empfangen Prozedur 
procedure TForm1.BildSocketClientRead(Sender: TObject;
  Socket: TCustomWinSocket);
var
  FStream: TFileStream;
  SizeOfFile: Integer;
  pBuffer: Pointer;
begin
  //Stream erstellen;
  FStream := TFileStream.Create(ExtractFilePath(paramstr(0))+'\scr.jpg', fmOpenWrite);
  //Zum füller Dateigröße empfangen
  SizeOfFile := Socket.ReceiveLength;
  //in den Buffer packen
  GetMem(pBuffer, SizeOfFile);
  //empfangen
  try
    Socket.ReceiveBuf(pBuffer^, SizeOfFile);
    FStream.Write(pBuffer^, SizeOfFile);
  finally
    FreeMem(pBuffer);
    FStream.Free;
  end;
end;

//Und zum Bild anzeigen
procedure TForm1.BildSocketClientDisconnect(Sender: TObject;
  Socket: TCustomWinSocket);
begin
  Image1.Picture.LoadFromFile(ExtractFilePath(paramstr(0))+'\scr.jpg');
end;

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 05.12.06 15:10 
Moin!

Wo hast du denn den Code her? :gruebel: Das kann nicht klappen, schon aus mehreren Gründen... :?

Schonmal das hier angesehen? ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Fighter#1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: Di 05.12.06 15:13 
Ich schaus mir an,
den Code hab ich aus der Library : www.delphi-library.d...erschicken_2632.html

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 05.12.06 15:24 
Moin!

Ja, dieser FAQ-Beitrag ist schon etwas älter und hat z.B. das Problem, nur bis 8kb großen Dateien zu funktionieren... (und ist abgesehen davon eh nicht wirklich sauber gelöst).

Ich habe mal bei den Mods vorgeschlagen, den Beitrag wieder zum Editieren freizugeben, dann kann man das da mal vermerken.

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Fighter#1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: Di 05.12.06 19:31 
... drum hats nie geklappt, und es sind nur exakt 8kb angekommen, danke

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse