So here is a pair of programs demonstrating the use of sockets on Linux. The server program is run first. Then whenever the client program is run, it connects to the server on the specified port and they both exchange strings and terminate. TCP is used over IPv4. Simple_tcpserver_ipv4.c: # include < stdio.h > # include < stdlib.h > # include < unistd.h > # include < string.h > # include < sys/types.h > # include < sys/socket.h > # include < netinet/in.h > # include < netdb.h > # include < arpa/inet.h > void error ( char * msg ) { perror ( msg ) ; exit ( 1 ) ; } int main ( int argc , char * argv [ ] ) { int sockfd , newsockfd , portno ; socklen_t clilen ; char buffer [ 256 ] ; struct sockaddr_in serv_addr , cli_addr ; int n ; if ( argc < 2 ) { fprintf ( stderr , " Usage: %s \n " , argv [ 0 ] ) ; exit ( 0 ) ; } ...