Hello
How to send a file from server to client.
I am a bigger in C with unix, i am trying to read a file from server and display it in client , i got a separate code to read a file , and i tried to connect the server and client with the following code is working fine only it shows a warning.
I am using the sample code from the follosing site
http://www2.ics.hawaii.edu/~esb/2003spring.ics651/hw1.html
the connection is working fine , but i dont know how to add the sending and receving code in to it and the text reading code in to that code...
if any one can help me , It would be much appreciated. Thank You for reading.
file reading code i am using is as fallows.
#include <stdio.h>
int main ( void )
{
static const char filename[] = "file.txt";
FILE *file = fopen ( filename, "r" );
if ( file != NULL )
{
char line [ 128 ]; /* or other suitable maximum line size */
while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */
{
fputs ( line, stdout ); /* write the line */
}
fclose ( file );
}
else
{
perror ( filename ); /* why didn't the file open? */
}
return 0;
}
Thank u