![]() |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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
|
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
I can send you a sample app... mail-me (lapince@lapince.com).
|
|
#5
|
|||
|
|||
|
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) |
|
#6
|
|||
|
|||
|
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 |
|
#7
|
|||
|
|||
|
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) |
![]() |
| Thread Tools | |
| Display Modes | |
|
|