C++ programs to transfer a Text file from server to client using TCP
The CPP files were compiled and ran on Ubuntu [WSL].
Direction of file Transfer: Server to Client.
The path of text file to send can be changed in the file_server.cpp
on line 37.
NOTE: The char array buffer
in file_client.cpp
is default to 1KB, you may need to increase the file size as per the larger file's size.
- Socket Programming basics : https://www.geeksforgeeks.org/socket-programming-cc/
-
inet_pton()
: http://man7.org/linux/man-pages/man3/inet_pton.3.html -
sockaddr_in
andin_addr
: https://www.gta.ufrj.br/ensino/eel878/sockets/sockaddr_inman.html -
socket()
: http://man7.org/linux/man-pages/man2/socket.2.html -
listen()
: http://man7.org/linux/man-pages/man2/listen.2.html -
accept()
: http://man7.org/linux/man-pages/man2/accept.2.html
- Copying whole text to string buffer before transmission
https://stackoverflow.com/questions/18398167/how-to-copy-a-txt-file-to-a-char-array-in-c
Good luck!