Reputation: 12997
I want to send a file in C++ over network (for a chat program) what should I do?
Upvotes: 0
Views: 10324
Reputation: 62333
Its quite easy. Set up a TCP/IP socket and then split the file into packets and send them across. TCP is reliable thus all the packets will arrive in the right order and it will handle re-transmission etc.
If, however, you need to use an unreliable transport (such as UDP) then look at stop and wait (Easiest), go-back-n or selective repeat (Which are both somewhat harder but far more efficient).
Upvotes: 1
Reputation: 6516
Use Open source FTP library for more robust application .Read this thread for c++ based open soruce library.
Upvotes: 1
Reputation:
You will be doing something called socket programming. Please refer Beej's Guide to Networking for all the details and the solution to your problem.
Upvotes: 0
Reputation: 416
Take a look at http://www.boost.org/doc/libs/1_38_0/doc/html/boost_asio/examples.html . The Iostreams example should give you the first good step. Asio is a portable network library of the boost project. Boost is available for most platforms available today.
You can stream in the file and stream out it into the TCP stream.
Upvotes: 4