View Single Post
Join Date: Nov 2008
Posts: 4
Reputation: manojn1979 is an unknown quantity at this point 
Solved Threads: 0
manojn1979 manojn1979 is offline Offline
Newbie Poster

UNIX Client and Server

 
0
  #1
Nov 29th, 2008
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/2003...cs651/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
Reply With Quote