Now this is a bit more of a request since I am not able to find
any simple and direct example for this.
Issue: I want to send a file from the server side to the client side.
When the server is already up and listening on a port and the client requests a file (file’s name being accepted as a parameter with the server IP address such as 127.0.0.1 and port no.)
and then the process of transfer starts till the file is copied.
Also can someone incorporate how can i measure the average transfer speed on the server side?
BTW: I am running Linux x86
Cheers,
echo9
Check Beej’s Guide to Network Programming. There are lots of examples there that shows how to implement a client/server architecture using sockets and send data between them.
EDIT:
Check items 8 and 9 from this tutorial for a complete example on client/server. Note that on item 8, the server sends a
char*to the client:On this case, it’s the
"Welcome to my server.\n"string, and the next parameter is the size of the string you want to send.When you need to send data from a file it’s the same thing: first, you need to read the data from the file and store it in a
char* buffer;that you manually allocated through malloc().Something like this: