Example #1
0
void *doServiceThread (void *f)
{
    int fd;
    fd = (int) f;
    doService(fd);
    pthread_exit(NULL);
}
Example #2
0
void doServiceFork(int fd) {
    int pid = fork();
    switch (pid){
        case -1: perror("Error creating server process");
            exit(1);
        case 0:
            doService(fd);
            exit(0);
    }
}
Example #3
0
void sequentialServerLoop(int socketFD)
{
    int connectionFD;
    connectionFD = acceptNewConnections (socketFD);
    if (connectionFD < 0)
    {
        perror ("Error establishing connection \n");
        deleteSocket(socketFD);
        exit (1);
    }
    doService(connectionFD);   
}
Example #4
0
/* Unbounded socket */
void doServiceFork (int fd)
{
    int pid;
    pid = fork();
    if(pid < 0){
        perror ("Error al crear hijo\n");
        exit(1);
    }
    if(pid == 0){
        doService(fd);
        exit(0);
    }
    NUM_CONECTIONS++;
}
Example #5
0
main (int argc, char *argv[])
{
  int socketFD;
  int connectionFD;
  char buffer[80];
  int ret;
  int port;


  if (argc != 2)
    {
      strcpy (buffer, "Usage: ServerSocket PortNumber\n");
      write (2, buffer, strlen (buffer));
      exit (1);
    }

  port = atoi(argv[1]);
  socketFD = createServerSocket(port);
  if (socketFD < 0)
    {
      perror ("Error creating socket\n");
      exit (1);
    }

  while (1) {
      connectionFD = acceptNewConnections (socketFD);
      if (connectionFD < 0)
      {
          perror ("Error establishing connection \n");
          deleteSocket(socketFD);
          exit (1);
      }

      doService(connectionFD);
  }
}