D
David
I have googled to no avail on getting specifically what I'm looking for. I
have found plenty of full blown apps that implement some type of file
transfer but what I'm specifcally looking for is an example to follow for
using a tcp socket to transfer files between client/server, server/client.
Both server and client are my program so I'm not looking for how to
implement an FTP client, or how to download a file from a web server via
http etc... Protocol between my client/server is a simple command based
structure and I intended on it going something like this in english:
this example is client to server scenario but I'll implement on both ends..
so client/server can be server/client etc..
1) client requests a file from server
2) server verifies file exists and sends back an 'ok' with the files size
(or message saying no file exists)
3) client receives file's size and sends the 'ok' to start the transfer
4) server sends file / client receives file
5) client sends 'ok' after receive is done
I've given these steps here to be clear and specific on the part I'm trying
to learn how to do. I can do all steps here fine except step 4, the actual
send/receive of the file. Help on that would be greatly appreciated.
I'm not even sure if those specific steps will stay like that, I only used
them to narrow down the area of my question. Further, I'm looking to do this
with the sockets directly, using socket.send and socket.receive, (or their
async methods), as I've read elseware that is the most effecient way, as
opposed to using a networkstream object. Aside from help on the specific
task I'm trying to learn, any comments on which technique is a good choice
are also welcome (socket.send etc... networkstream object.. and I honestly
just saw a 'socket.sendfile' method in VS help before finishing drafting
this post... I'm posting anyway since I learn a lot from this forum, and
even if one of the higher level classes is a better choice, I want to learn
the socket way first.)
have found plenty of full blown apps that implement some type of file
transfer but what I'm specifcally looking for is an example to follow for
using a tcp socket to transfer files between client/server, server/client.
Both server and client are my program so I'm not looking for how to
implement an FTP client, or how to download a file from a web server via
http etc... Protocol between my client/server is a simple command based
structure and I intended on it going something like this in english:
this example is client to server scenario but I'll implement on both ends..
so client/server can be server/client etc..
1) client requests a file from server
2) server verifies file exists and sends back an 'ok' with the files size
(or message saying no file exists)
3) client receives file's size and sends the 'ok' to start the transfer
4) server sends file / client receives file
5) client sends 'ok' after receive is done
I've given these steps here to be clear and specific on the part I'm trying
to learn how to do. I can do all steps here fine except step 4, the actual
send/receive of the file. Help on that would be greatly appreciated.
I'm not even sure if those specific steps will stay like that, I only used
them to narrow down the area of my question. Further, I'm looking to do this
with the sockets directly, using socket.send and socket.receive, (or their
async methods), as I've read elseware that is the most effecient way, as
opposed to using a networkstream object. Aside from help on the specific
task I'm trying to learn, any comments on which technique is a good choice
are also welcome (socket.send etc... networkstream object.. and I honestly
just saw a 'socket.sendfile' method in VS help before finishing drafting
this post... I'm posting anyway since I learn a lot from this forum, and
even if one of the higher level classes is a better choice, I want to learn
the socket way first.)