lunp
 Tutto Strutture dati File Funzioni Variabili Ridefinizioni di tipo (typedef) Tipi enumerati (enum) Valori del tipo enumerato Definizioni
Funzioni | Variabili
Riferimenti per il file mytcpserver.c
#include "lunp.h"

Funzioni

static void tcpServerPreforked (SOCKET sockfd, int childCount, myTcpServerChildTask childTask)
 
static void tcpServerOCPC (SOCKET sockfd, myTcpServerChildTask childTask, bool resetSigInt)
 
static void tcpServerOCPCMax (SOCKET sockfd, int maxChildCount, myTcpServerChildTask childTask, bool resetSigInt)
 
static void waitForZombieChildren ()
 
static void sigchldHandler (int s)
 
static void sigintHandler (int s)
 
SOCKET myTcpServerAccept (SOCKET sockfd, struct sockaddr_in *clientStruct)
 Accetta una connessione sul socket TCP specificato. Continua...
 
SOCKET myTcpServerStartup (const char *serverPort)
 Crea un socket TCP associato alla porta specificata. Continua...
 
void myTcpServerSimple (SOCKET sockfd, myTcpServerChildTask childTask)
 Implementa un server TCP che serve un client per volta. Continua...
 
void myTcpServerOCPC (SOCKET sockfd, myTcpServerChildTask childTask)
 Implementa un server TCP che serve più client tramite il fork di più processi figlio, uno per client. Continua...
 
void myTcpServerOCPCMax (SOCKET sockfd, int maxChildCount, myTcpServerChildTask childTask)
 Implementa un server TCP che serve fino a maxChildCount client tramite il fork di più processi figlio, uno per client. Continua...
 
void myTcpServerPreforked (SOCKET sockfd, int childCount, myTcpServerChildTask childTask)
 Implementa un server TCP che serve fino a childCount client tramite il pre-fork di childCount processi figlio. Continua...
 
void myTcpServerMixed (SOCKET sockfd, int minChildCount, myTcpServerChildTask childTask)
 Implementa un server TCP che serve più client tramite il pre-fork di minChildCount processi figlio. Continua...
 
void myTcpServerMixedMax (SOCKET sockfd, int minChildCount, int maxChildCount, myTcpServerChildTask childTask)
 Implementa un server TCP che serve fino a maxChildCount client tramite il pre-fork di minChildCount processi figlio. Continua...
 
void myTcpServerSelect (SOCKET sockfd, int maxChildCount, myTcpServerSelectChildTask childTask)
 Implementa un server TCP che serve fino a maxChildCount client nello stesso processo. Continua...
 

Variabili

static int numChildren_ocpc = 0
 
static int numChildren_preforked = 0
 
static pid_t * childpids
 

Documentazione delle funzioni

SOCKET myTcpServerAccept ( SOCKET  sockfd,
struct sockaddr_in *  clientStruct 
)

Accetta una connessione sul socket TCP specificato.

Parametri
sockfdIl file descriptor del socket TCP su cui accettare la connessione.
Valori di ritorno
clientStructLa struttura contenente le informazioni sul client.
Restituisce
Restituisce il file descriptor del socket TCP accettato.
void myTcpServerMixed ( SOCKET  sockfd,
int  minChildCount,
myTcpServerChildTask  childTask 
)

Implementa un server TCP che serve più client tramite il pre-fork di minChildCount processi figlio.

Parametri
sockfdIl file descriptor del socket a cui i client si connettono.
minChildCountIl numero minimo di processi figlio generati con il pre-fork.
childTaskLa funzione da chiamare ogni volta che un client si connette al socket sockfd.
Avvertimento
Questa funzione non ritorna mai.
void myTcpServerMixedMax ( SOCKET  sockfd,
int  minChildCount,
int  maxChildCount,
myTcpServerChildTask  childTask 
)

Implementa un server TCP che serve fino a maxChildCount client tramite il pre-fork di minChildCount processi figlio.

Parametri
sockfdIl file descriptor del socket a cui i client si connettono.
minChildCountIl numero minimo di processi figlio generati con il pre-fork.
maxChildCountIl numero massimo di client da servire allo stesso tempo.
childTaskLa funzione da chiamare ogni volta che un client si connette al socket sockfd.
Avvertimento
Questa funzione non ritorna mai.
void myTcpServerOCPC ( SOCKET  sockfd,
myTcpServerChildTask  childTask 
)

Implementa un server TCP che serve più client tramite il fork di più processi figlio, uno per client.

Parametri
sockfdIl file descriptor del socket a cui i client si connettono.
childTaskLa funzione da chiamare ogni volta che un client si connette al socket sockfd.
Avvertimento
Questa funzione non ritorna mai (nel processo padre).
void myTcpServerOCPCMax ( SOCKET  sockfd,
int  maxChildCount,
myTcpServerChildTask  childTask 
)

Implementa un server TCP che serve fino a maxChildCount client tramite il fork di più processi figlio, uno per client.

Parametri
sockfdIl file descriptor del socket a cui i client si connettono.
maxChildCountIl numero massimo di client da servire allo stesso tempo.
childTaskLa funzione da chiamare ogni volta che un client si connette al socket sockfd.
Avvertimento
Questa funzione non ritorna mai (nel processo padre).
void myTcpServerPreforked ( SOCKET  sockfd,
int  childCount,
myTcpServerChildTask  childTask 
)

Implementa un server TCP che serve fino a childCount client tramite il pre-fork di childCount processi figlio.

Parametri
sockfdIl file descriptor del socket a cui i client si connettono.
childCountIl numero massimo di client da servire allo stesso tempo.
childTaskLa funzione da chiamare ogni volta che un client si connette al socket sockfd.
Avvertimento
Questa funzione non ritorna mai.
void myTcpServerSelect ( SOCKET  sockfd,
int  maxChildCount,
myTcpServerSelectChildTask  childTask 
)

Implementa un server TCP che serve fino a maxChildCount client nello stesso processo.

Parametri
sockfdIl file descriptor del socket a cui i client si connettono.
maxChildCountIl numero massimo di client da servire allo stesso tempo.
childTaskLa funzione da chiamare ogni volta che un client si connette al socket sockfd.
Avvertimento
Questa funzione non ritorna mai.
void myTcpServerSimple ( SOCKET  sockfd,
myTcpServerChildTask  childTask 
)

Implementa un server TCP che serve un client per volta.

Parametri
sockfdIl file descriptor del socket a cui i client si connettono.
childTaskLa funzione da chiamare ogni volta che un client si connette al socket sockfd.
Avvertimento
Questa funzione non ritorna mai.
SOCKET myTcpServerStartup ( const char *  serverPort)

Crea un socket TCP associato alla porta specificata.

Parametri
serverPortLa porta del server a cui associare il socket creato.
Restituisce
Restituisce il file descriptor del socket TCP creato.
static void sigchldHandler ( int  s)
static
static void sigintHandler ( int  s)
static
static void tcpServerOCPC ( SOCKET  sockfd,
myTcpServerChildTask  childTask,
bool  resetSigInt 
)
static
static void tcpServerOCPCMax ( SOCKET  sockfd,
int  maxChildCount,
myTcpServerChildTask  childTask,
bool  resetSigInt 
)
static
static void tcpServerPreforked ( SOCKET  sockfd,
int  childCount,
myTcpServerChildTask  childTask 
)
static
static void waitForZombieChildren ( )
static

Documentazione delle variabili

pid_t* childpids
static
int numChildren_ocpc = 0
static
int numChildren_preforked = 0
static