/* ss1.c */

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <signal.h>

int32_t sockfd;

void catcher(int sig)
{
close(sockfd);
exit(0);
} /* catcher */

int main()
  {
    char c;
    struct sockaddr_in server ={AF_INET, 7000, INADDR_ANY};

    sockfd = socket(PF_INET, SOCK_STREAM, 0);
    if( sockfd == -1)
    {
      printf("can not create socket");
      exit(-1);
    } /* if */
    signal(SIGPIPE, catcher);
 
    if( bind(sockfd,(struct sockaddr*) &server, 
               sizeof(server)) == -1)
    {
      perror("bind");
      exit(1);
    } /* if */
 
    if(listen(sockfd, 10) == -1)
    {
      perror("listen");
      exit(1);
    }/* if */
 
    for(; ;)
    {
      int32_t newsockfd = accept(sockfd, NULL, NULL);
 
      if (newsockfd < 0)
      {
        perror("accept");
        exit(1);
      } /* if */
 
     // perform read write operations ...
 
      if ( fork() == 0)
      {
        printf("Received: ");
        while( recv(newsockfd, &c, 1, 0) > 0)
        {
           putchar(c);
           c = toupper(c);
           send(newsockfd, &c, 1, 0);
        } /* while */

        /* if the client is no longer sending information,
           the socket can be closed and the child process 
           terminated  */

        putchar('\n');
        close(newsockfd);
        exit(0);
      }/* if */ 
        close(newsockfd); // parent
    }
    return 0;
  }

____________________________________________________________

% ./ss1
Received: Good bye World!


