Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 01-26-2001, 09:32 AM
deleteme deleteme is offline
Member
 
Join Date: Jan 2001
Posts: 33
Default Anybody can give me an example to send files over TCP/IP

Hi DelphiFreaks,

I want to send an image oevr the TClient/Server- Socket, I know how to send textfiles with shose components, but a file is more difficult i think, anybody know a simple example to do this?

greetz, ruben
Reply With Quote
  #2  
Old 01-26-2001, 12:14 PM
Wise Guy Wise Guy is offline
Member
 
Join Date: Jan 2001
Posts: 45
Default RE: Anybody can give me an example to send files over TCP/IP

The way to send a file over TCP socket is by using the SendBuf method. DON'T USE THE SENDTEXT, 'cos it truncates the #0 (empty chars in the string). So... read the file and send it with SendBuf. That's all
Reply With Quote
  #3  
Old 01-26-2001, 12:20 PM
deleteme deleteme is offline
Member
 
Join Date: Jan 2001
Posts: 33
Default RE: RE: Anybody can give me an example to send files over TCP/IP

h, thanks 4 your reaction,

Yes, i do understand that, but i am a little bit a newbie in this stuff, i know that i will have to send it with SendBuffer, but how to receive it? and i heard it cannot be larger than 128k, how can you divide it into smaller portions?

greetz, ruben
Reply With Quote
  #4  
Old 01-26-2001, 01:12 PM
Lapince Lapince is offline
Senior Member
 
Join Date: Jan 2001
Posts: 163
Default RE: RE: RE: Anybody can give me an example to send files over TCP/IP

I can send you a sample app... mail-me (lapince@lapince.com).
Reply With Quote
  #5  
Old 01-26-2001, 01:17 PM
Wise Guy Wise Guy is offline
Member
 
Join Date: Jan 2001
Posts: 45
Default RE: RE: RE: Anybody can give me an example to send files over TCP/IP

Hey!

Assuming You're using a NONBLOCKING client/server type (otherwise you have no business with endBuf/ReceiveBuf), here is some code for receiving the sent buffer:

procedure TForm1.MyServerSocketOnClientRead(Sender: Object;Socket: TCustomWinSocket);
var Buf : Array [1..1024] of Char;
begin
If MyServerSocket.Socket.RECEIVEBUF(Buf,1024) > -1 then
... //for exmaple update the destination file
end;

There's something you should remember - it's important! You should coordinate both actions of sending and receiving the BUFFERS - i mean while the destination part is not accepted do not send another buffer, otherwise packet lost may occur. For more information mail me at: javor@nbis.net (ofr example if you want a bigger piece of code)
Reply With Quote
  #6  
Old 01-27-2001, 10:53 PM
deleteme deleteme is offline
Member
 
Join Date: Jan 2001
Posts: 33
Default RE: Anybody can give me an example to send files over TCP/IP

Hi, It's me (Ruben, but i changed my name to a nickname since everybode has one at this place :-))

I tryd both examples you guys send to me, Thanx a lot, but i have one question about them, you both use the client to send the information, is it possible to use the server to send, and the client to receive? (That's because i already have a working program, and that is based on: Server is waiting till client makes connection, then it is time to send info (and now, that info must include an image).

A second question is: Now i can send files over the network, but that is from HardDisk to HardDisk (with that assign-stuff), is it also possible to send it as a TBitMap? I mean, if i make a painting program, wich will send the painting e.g. every second, it would be time-wasting to save it first to HardDisk and then get it back into memory and then send it.

Well, that's it, thanx again, and sorry for my bad english :-(

Greetz, Ruben
Reply With Quote
  #7  
Old 01-28-2001, 02:27 AM
Lapince Lapince is offline
Senior Member
 
Join Date: Jan 2001
Posts: 163
Default RE: RE: Anybody can give me an example to send files over TCP/IP

First, yes, you can use server to send files instead of client. You'll have to change some small things, I think, but that's all.
Second, using Streams, you can receive data to a stream, and then use TBitmap.LoadFromStream.

If you have problem, mail-me (lapince@lapince.com)
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 12:01 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.