http://www.cis.gvsu.edu/~wolffe/courses/cs656/projects/tutorial_CSockets.html
line 88: write() takes a char* as the 2nd parameter
all you have to do is convert the filename accordingly
then read() it on the client side into another char* buffer
You're missing an important loop for processing the server messages.
I've only done it in a windows environment but it basically starts like this:
//ReceiveProtocolMessage(lParam)
{
switch(lParam)
{
case FD_READ:
case FD_WRITE:
case FD_ACCEPT: //Connection request to server
case FD_CONNECT:
case FD_CLOSE:
}
}
I'm not sure if it's best, but the way I would do it is open a txt or data file and output the results and filename there. Then, once a certain quota size is reached, open/read that file and load the char* buffer to send to the client.
Then the client side would be similar. Process the data file once it reaches a certain quota that you decide on.
A couple things to keep in mind.
1-There is a limit to how much the buffer can hold.
2-There could be an error or an incomplete data packet that is sent over the network due to various reasons.
So, good practice is to always put a unique terminating sequence of chars that is always tested for on the other side of the server. That way you can be sure that the entire msg was sent and either resend or do something else if it was incomplete.
like: "myfilename.exe=-+="