0

Hello....i am trying to send a file from server to the client using socket programming in C, how do i do this?? basically the client is trying to download a file from the server....

2
Contributors
5
Replies
8
Views
5 Years
Discussion Span
Last Post by L7Sqr
0

There are several online networking tutorials online (Beej is a good google term) - I'll assume that you have read these and will ask direct questions on points you do not understand.
The answer to your question, then, is that you

  • open socket, listen and accept the client connection
  • read from the client what file to serve
  • open the file on the server
  • read the file chunk by chunk
  • each chunk read from file should be written to the socket
  • close file
  • close socket
0

i understood the procedure to do it, but i am new to socket programming so i am looking for some code that helps me in transferring files....

0

i had already gone through beej's guide, but it doesn't describe about files anywhere in the book....

Beej

0

The examples on that site direct you how to send information over a network connection. To send a file, just open your file, read from it and write what was read to the network socket.

Specifically, look at this part and instead of the char * used in that code substitute the data from your file.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.