My Project
Functions
connection.h File Reference

Header for the connection-handling module. More...

Go to the source code of this file.

Functions

int initConnectionHandler (void)
 Initializes the connection-handling module. More...
 
void handleConnection (int clientSock, int listenSock)
 Handles an incoming connection. More...
 

Detailed Description

Header for the connection-handling module.

Function Documentation

◆ handleConnection()

void handleConnection ( int  clientSock,
int  listenSock 
)

Handles an incoming connection.

This function should be called from the main module whenever a new connection has been accepted.

Parameters
clientSockSocket representing the accepted connection from the client. Upon completing the request or as soon as it is no longer needed, this socket is closed.
listenSockSocket the server is listening on. If the implementation launches a child process to handle the connection, this socket must be closed in that child process.

◆ initConnectionHandler()

int initConnectionHandler ( void  )

Initializes the connection-handling module.

Note
This function must be invoked after cmdlineInit().
It is the responsibility of this function to initialize the request-handling module by calling initRequestHandler().
Returns
0 on success, -1 if the command-line arguments are invalid. If a non-recoverable error occurs during initialization (e.g. a failed memory allocation), the function does not return, but instead prints a meaningful error message and terminates the process.