Board index » cppbuilder » Send a file over TCP Socket

Send a file over TCP Socket


2005-03-07 05:03:48 PM
cppbuilder24
Hi how can i send a file over tcp socket connection?I have allredy have a
server which receive the file.BUt I dont know how can i sen file from
client?
Sould i use Socket->Send() method ?but how?
Can you give a sample?
 
 

Re:Send a file over TCP Socket

mehmed sipahi wrote:
Quote
Hi how can i send a file over tcp socket connection?I have allredy have a
server which receive the file.BUt I dont know how can i sen file from
client?
Sould i use Socket->Send() method ?but how?
Use Socket->SendBuf().
Please explain more exact what the problem is.
Can you send other data ?
Please read some actual threads in this newsgroup concerning
SendBuf().
Hans.
 

Re:Send a file over TCP Socket

I think it's the ultimate time that Remy publishes the code
(faq) he presented here many times, and so just redirect all
similar questions.
I haven't counted but it's maybe 20th time that the same
question reappears ;)
--
Best regards,
Vladimir Stefanovic
"Hans Galema" < XXXX@XXXXX.COM >wrote in message
Quote
mehmed sipahi wrote:
>Hi how can i send a file over tcp socket connection?I have allredy have a
>server which receive the file.BUt I dont know how can i sen file from
>client?
>Sould i use Socket->Send() method ?but how?

Use Socket->SendBuf().

Please explain more exact what the problem is.

Can you send other data ?

Please read some actual threads in this newsgroup concerning
SendBuf().

Hans.
 

{smallsort}

Re:Send a file over TCP Socket

Look at the thread from 11. januar 2005 19:41
'please help me..socket file transfer'
--
Best regards,
Vladimir Stefanovic
"mehmed sipahi" < XXXX@XXXXX.COM >wrote in message
Quote
Hi how can i send a file over tcp socket connection?I have allredy have a
server which receive the file.BUt I dont know how can i sen file from
client?
Sould i use Socket->Send() method ?but how?

Can you give a sample?




 

Re:Send a file over TCP Socket

"Vladimir Stefanovic" < XXXX@XXXXX.COM >wrote in message
Quote
I think it's the ultimate time that Remy publishes the
code (faq) he presented here many times, and so just
redirect all similar questions.
All code I have ever published in these newsgroups is publically available
in the archives www.deja.com and www.mers.com
Gambit
 

Re:Send a file over TCP Socket

remy's code works perfectly...can you please tell me what changes should be
made in order to
see the download speed and how many bytes remain for download?this 2 things
i would like to be visible to the client and to the server too.. thank you
very much in advance for your help
?"mehmed sipahi" < XXXX@XXXXX.COM >έγραψε στ?μήνυμα
Quote
Hi how can i send a file over tcp socket connection?I have allredy have a
server which receive the file.BUt I dont know how can i sen file from
client?
Sould i use Socket->Send() method ?but how?

Can you give a sample?




 

Re:Send a file over TCP Socket

lakis wrote:
Quote
remy's code works perfectly...
Which code are you referring to ?
Quote
can you please tell me what changes should be
made in order to
see the download speed and how many bytes remain for download?
To whom are you addressing yourself ?
Hans.
 

Re:Send a file over TCP Socket

as vladimir said remy posted a code for file send over tcp socket
(Look at the thread from 11. januar 2005 19:41
'please help me..socket file transfer')the code works excellent.i place a
client socket on one computer and a
server socket on another computer and i send file from server to client
using that code.
what changes should be made to this code in order to see also to the client
and to the server side
the download speed and the bytes remaining....i can post remys code again if
neccessary.
?"Vladimir Stefanovic" < XXXX@XXXXX.COM >έγραψε στ?μήνυμα
Quote
Look at the thread from 11. januar 2005 19:41
'please help me..socket file transfer'


--
Best regards,
Vladimir Stefanovic
"mehmed sipahi" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...
>Hi how can i send a file over tcp socket connection?I have allredy have
a
>server which receive the file.BUt I dont know how can i sen file from
>client?
>Sould i use Socket->Send() method ?but how?
>
>Can you give a sample?
>
>
>
>


 

Re:Send a file over TCP Socket

lakis wrote:
Quote
what changes should be made to this code in order to see also to the client
and to the server side
the download speed and the bytes remaining....i can post remys code again if
neccessary.
Well what is the problem with that ? On the sending side you can leave
all code as it is. You know at forehand the size of the data. A while loop
is used to send chuncks of data. So at every moment you know how
much is sent. If you use GetTickCount() you know bytes/ms. So you
only have to ad some code in that loop.
Hans.
 

Re:Send a file over TCP Socket

well i understand what u mean,and it seems simple i will work on it.now one
final question and really sorry for the trouble of continuous
questions..basically its a rather stupid question but im new in
programming.:if i use indy trivial ftp components for file transfer means i
am using trivial ftp protocol,if i use indy ftp components for file transfer
means i am using ftp protocol etc. when i send
file through sockets in this way what protocol am i using?(or im not using
any protocol at all?) i mean that trivial ftp,ftp,icmp,http, etc protocols
have some security...through sockets which protocol am i using ?(in order to
understand what security is provided)
? "Hans Galema" < XXXX@XXXXX.COM >?????? ??? ??????
Quote
lakis wrote:

>what changes should be made to this code in order to see also to the
client
>and to the server side
>the download speed and the bytes remaining....i can post remys code
again if
>neccessary.

Well what is the problem with that ? On the sending side you can leave
all code as it is. You know at forehand the size of the data. A while loop
is used to send chuncks of data. So at every moment you know how
much is sent. If you use GetTickCount() you know bytes/ms. So you
only have to ad some code in that loop.

Hans.
 

Re:Send a file over TCP Socket

lakis wrote:
Quote
... now one
final question and really sorry for the trouble of continuous
questions..
You can ask as many questions as you want. That is no trouble at all.
You only way you cause trouble is by not writing in a normal way
with a kapital letter at the start of a sentence. Is your shift key
blocked ?
Quote
if i use indy trivial ftp components for file transfer means i
am using trivial ftp protocol,if i use indy ftp components for file transfer
means i am using ftp protocol etc.
No both use the same ftp protocol. They could also connect to the
same server because the server speaks ftp.
Quote
when i send
file through sockets in this way what protocol am i using?(or im not using
any protocol at all?)
You use a protocol. But it has no name. A protocol is the way a client
and a server exchange messages. If the server send you a bunch of data
then it can for instance send four bytes (an int) first with the size
of the message. A client has to read that size first. As simple as it
is: this is a protocol. You have to know that the size comes first and
act accordingly.
Hans.
 

Re:Send a file over TCP Socket

Well basically i use the Caps Lock istead of the shift key..:)).By the way
ftp and trivial ftp are diffrent things
FTP:FTP is commonly run on two ports, 20 and 21. Port 20 is a data stream
which transfers the data between the client and the server. Port 21 is the
control stream and is the port where commands are passed to the ftp
server.FTP is an 8-bit client-server protocol,
TRIVIAL FTP:Trivial File Transfer Protocol (TFTP) is a very simple file
transfer protocol akin to a basic version of FTP
a.. Uses UDP (port 69) as its transport protocol (unlike FTP which uses
TCP port 21).
b.. It cannot list directory contents
c.. No authentication or encryption mechanisms
d.. Used to read files from/write files to a remote server
e.. Supports three different transfer modes, "netascii", "octet" and
"mail", with the first two corresponding to the "ascii" and "image" (binary)
modes of the FTP protocol.
from en.wikipedia.org/
so ftp and trivial ftp arent exactly the same protocols, are they?
? "Hans Galema" < XXXX@XXXXX.COM >?????? ??? ??????
Quote
lakis wrote:
>... now one
>final question and really sorry for the trouble of continuous
>questions..

You can ask as many questions as you want. That is no trouble at all.
You only way you cause trouble is by not writing in a normal way
with a kapital letter at the start of a sentence. Is your shift key
blocked ?

>if i use indy trivial ftp components for file transfer means i
>am using trivial ftp protocol,if i use indy ftp components for file
transfer
>means i am using ftp protocol etc.

No both use the same ftp protocol. They could also connect to the
same server because the server speaks ftp.

>when i send
>file through sockets in this way what protocol am i using?(or im not
using
>any protocol at all?)

You use a protocol. But it has no name. A protocol is the way a client
and a server exchange messages. If the server send you a bunch of data
then it can for instance send four bytes (an int) first with the size
of the message. A client has to read that size first. As simple as it
is: this is a protocol. You have to know that the size comes first and
act accordingly.

Hans.
 

Re:Send a file over TCP Socket

and also tftp:Standard 33/RFC 1350
(www.rfc-editor.org/rfc/std/std33.txt) "The TFTP protocol (revision
2)" insteed of ftp:The protocol is standardized in RFC 0959 by the IETF
? "Hans Galema" < XXXX@XXXXX.COM >?????? ??? ??????
Quote
lakis wrote:
>... now one
>final question and really sorry for the trouble of continuous
>questions..

You can ask as many questions as you want. That is no trouble at all.
You only way you cause trouble is by not writing in a normal way
with a kapital letter at the start of a sentence. Is your shift key
blocked ?

>if i use indy trivial ftp components for file transfer means i
>am using trivial ftp protocol,if i use indy ftp components for file
transfer
>means i am using ftp protocol etc.

No both use the same ftp protocol. They could also connect to the
same server because the server speaks ftp.

>when i send
>file through sockets in this way what protocol am i using?(or im not
using
>any protocol at all?)

You use a protocol. But it has no name. A protocol is the way a client
and a server exchange messages. If the server send you a bunch of data
then it can for instance send four bytes (an int) first with the size
of the message. A client has to read that size first. As simple as it
is: this is a protocol. You have to know that the size comes first and
act accordingly.

Hans.
 

Re:Send a file over TCP Socket

lakis wrote:
Quote
By the way
ftp and trivial ftp are diffrent things
[....]
so ftp and trivial ftp arent exactly the same protocols, are they?
Then yes they are different Thanks for pointing that out.
Learned again something.
Hans.