<P>
heh now just change the message "hello client" from server to any<BR>
command you want to run ( eg. ls ) and change the message<BR>
"hello server" from the client to the output of the command. thats<BR>
it.<BR>
<BR>
mehul.<BR>
<BR>
On Fri, 27 Feb 2004 subin jose wrote :<BR>
>u can do that using calls write() and read()<BR>
>but before that socket descriptors are to be created using socket() call and binded to the port u want to listen to using bind()call basic algorithm needed for both client and server is below<BR>
>server<BR>
><BR>
>For Server<BR>
>1. Create a socket descriptor of family internet(AF_INET) and type TCP (SOCK_STREAM) using the procedure call socket()<BR>
>2. portno to be used is read from the user and converted to networkbyte order using htons().<BR>
>3. Declare a variable of structure sockaddr_in to store server details and initialise the members<BR>
>4. Bind the variable with the socket descriptor using the call bind()<BR>
><BR>
>5. Listen for any incoming connections at socket descriptor using call listen()<BR>
>6. Accept any request for connection using call accept()which returns a new socket descriptor for the connection<BR>
>7.use call write() to write to the connected client<BR>
>9. Close the connection using call close()<BR>
>For Client<BR>
>1. Create a socket descriptor of family internet(AF_INET) and type TCP (SOCK_STREAM) using the procedure call socket()<BR>
>2. portno to be used is read from the user and converted to networkbyte order.<BR>
>3. Host name is read from the user and is converted to the address using a function call gethostbyname()which returns a pointer to astructure of type hostent which contains the fields addr for the address and length which stores the length of the address.<BR>
>4. Declare a variable of structure sockaddr_in to store server details and initialise the members using values from the above.<BR>
>5. Bind the variable with the socket descriptor using the call bind()<BR>
>6. Connect to the server using the call connect()<BR>
>7. Read the contents transmitted from server using the call read()<BR>
>8. close the connection<BR>
><BR>
>for more details goto this link its a beautiful tutorial for beginners<BR>
><BR>
>http://www.ecst.csuchico.edu/~beej/guide/net/html/<BR>
><BR>
><BR>
>> From: "mehul radheshyam choube" <mrc_cprog@rediffmail.com><BR>
>>Reply-To: linuxcprogramming@lists.linux.org.au<BR>
>>To: linuxcprogramming@lists.linux.org.au<BR>
>>CC: "subin jose" <scorpiosubin@hotmail.com><BR>
>>Subject: Re: [LCP]question<BR>
>>Date: 26 Feb 2004 12:23:25 -0000<BR>
>><BR>
>>explain me how will you send a string "hello client" from the<BR>
>>server to the client program and recieve back a string<BR>
>>"hello server" from the client.<BR>
>><BR>
>>mehul.<BR>
>><BR>
>><BR>
>>On Mon, 23 Feb 2004 subin jose wrote :<BR>
>> ><BR>
>> >hi<BR>
>> ><BR>
>> >i am a beginner in c network programming and i want to implement the following.<BR>
>> ><BR>
>> >i have two systems a server and a client.suppose the server requests some program in the client to be run(any program like simple addition to system calls to shutdown the system).i want the server to send the program name to client excecute the program there send back whatever is the result to the server.also i am using a stream socket<BR>
>> ><BR>
>> >thank you<BR>
>> ><BR>
>> >subin<BR>
>> ><BR>
>> >_________________________________________________________________<BR>
>> >Post Classifieds on MSN classifieds. http://www.sulekha.com/msnclassifieds Buy and Sell on MSN Classifieds.<BR>
>> ><BR>
>> >_______________________________________________<BR>
>> >This is the Linux C Programming List<BR>
>> >: http://lists.linux.org.au/listinfo/linuxcprogramming List<BR>
>><BR>
><BR>
>_________________________________________________________________<BR>
>INDIA TODAY @ Rs. 5 for 5 years ! http://www.indiatoday.com/itoday/intlsubscription/itsubs/it_offer.html Subcribe Now ...<BR>
><BR>
>_______________________________________________<BR>
>This is the Linux C Programming List<BR>
>: http://lists.linux.org.au/listinfo/linuxcprogramming List<BR>
</P>
<br><br>
<A target="_blank" HREF="http://clients.rediff.com/signature/track_sig.asp"><IMG SRC="http://ads.rediff.com/RealMedia/ads/adstream_nx.cgi/www.rediffmail.com/inbox.htm@Bottom" BORDER=0 VSPACE=0 HSPACE=0 HEIGHT=74 WIDTH=496></a>