client <-> server interaction in C

Jeremy Huntwork jhuntwork at
Tue Nov 22 10:33:24 PST 2005

Gerard Beekmans wrote:
> The next bit of code I'd like to test out would be the client sending a 
> command to the server which the server will execute. That shouldn't be 
> hard I don't think.

Looks good. :) Except, for the sake of accuracy, you're missing some 

client.c needs:
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>

server.c needs:
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <netinet/in.h>

Turning on -Wall and -pedantic shows some warnings without those.

As far as executing, I suppose you could just have the server pass 
whatever text it receives from the client (except if it's in a special 
format) to a system call. Of course, eventually we'd want to figure out 
some authentication.


More information about the alfs-discuss mailing list