Autor Beitrag
JacFab
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 111



BeitragVerfasst: Mi 27.11.02 23:08 
Mein Code sieht bisher so aus:
ausblenden Quelltext
1:
2:
3:
4:
5:
var Stream: TFileStream; 
begin 
  Stream:=TFileStream.Create('C:\Hallo.bmp',fmOpenRead); 
  ServerSocket.Socket.SendStream(Stream) 
end;

Nun weiß ich aber nicht, wie man auf der Empfängerseite die Datei nun einließt!

Wie sieht der Code da aus?

Gruß JaC

(28.11. 08:58 Tino) Code-Tags hinzugefügt.
patmann2001
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 201

Windows 7 Prof.
Delphi XE2
BeitragVerfasst: Do 28.11.02 07:31 
Ich habe mich leider noch nicht mit Sreams befast, aber ich denke es geht so
Zuerst mal das Ereignis OnClientRead
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TLanChat_Form.ClientSocket1Read(Sender: TObject;
  Socket: TCustomWinSocket);
  VAR Stream: TFileStream;
      stream:TWinSocketStream;
      Buffer:TStream;

begin
   stream := TWinSocketStream.Create(socket,1000);
   stream.Read(Buffer,stream.Size);
   stream.Free;
   {weiterer Code}
end;

Wie gesagt, ich habe das nicht probiert. Könnte aber klappen

cu Patmann
DeCodeGuru
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1333
Erhaltene Danke: 1

Arch Linux
Eclipse
BeitragVerfasst: Do 28.11.02 17:59 
hi,

@patmann2001: Dein Code kann nit funtzen, weil du eine Variable redefiniert hast. Zwei Variable mit gleichen Namen geht nu ma nit so rischtisch :wink:

Zum Problem: Ein Blick ins FAQ hilft manchmal :mrgreen:

Hier gehts zum FAQ

_________________
Viele Grüße
Jakob
patmann2001
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 201

Windows 7 Prof.
Delphi XE2
BeitragVerfasst: Fr 29.11.02 15:21 
Upps
Da hab ich wohl geschlafen
Sorry
cu Patmann
ChristianK
Hält's aus hier
Beiträge: 3



BeitragVerfasst: So 29.12.02 01:34 
Hi,
das Senden einer Datei kann man auch mit der Fastnet Komponente nmstrm bzw. nmstrmserv realisieren. Mit nmstrm1.postit(Stream) verschickt man den Stream und um den Stream empfangen zu können braucht man das Ereignis OnMSG von nmstrmserv. Die Variable strm enthält den ankommenden Stream, den man dann einfach in einen Filestream kopiert und als Datei auf der Platte abspeichert.
Die angegebene Lösung ist aber auch nicht schlecht !

_________________
Legends may sleep, but they never die
( by Kim Schmitz, fettest Hacker in the world )
ChristianK
Hält's aus hier
Beiträge: 3



BeitragVerfasst: So 29.12.02 17:10 
Komisch, der Code aus der FAQ funktioniert bei mir doch nicht. Die empfangene Datei ist bei mir nachher nur 128 byte groß. Ich hab aber alles genauso gemacht wie im Quelltext beschrieben. Woran liegt das ??

_________________
Legends may sleep, but they never die
( by Kim Schmitz, fettest Hacker in the world )