![]() |
| ||
| UNIX Client and Server 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 |
| ||
| Re: UNIX Client and Server This isnt an intro. Moved to the C board. |
| ||
| Re: UNIX Client and Server Hi I can't get you... What does it mean move to c board. |
| ||
| Re: UNIX Client and Server It was originally posted in the board which is for welcoming new members, so I moved it to the C programming language board, as it is indeed a question about C programming. |
| ||
| Re: UNIX Client and Server Thank You. |
| ||
| Re: UNIX Client and Server I'm no expert in socket programming, but i think these functions might be of some use. send() to send dataHope i helped. |
| ||
| Re: UNIX Client and Server Hi thank u for the reply. I got changed the code to following , now i am able to send a file from server to client . That means send A from server and Save as B in client. Server code #include <stdio.h> Client Code
Now i am trying to read B and display in client , for that i changed the following code and inserted it in to the client code but it say file is alread open..... so i am not able to display the B in client. What is the point in code i am missing out , how to cahge the following code to display the file B in client. static const char filename[] = "file.txt"; Thank You for readying. |
| All times are GMT -4. The time now is 2:52 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC