More extraction of functionality
Extracting server and tty functions into separate headers. Thread functions for new connections, tty data and client data are also extracted and used as separate functional blocks.
This commit is contained in:
parent
2c26ef201a
commit
c17e696566
11 changed files with 534 additions and 393 deletions
37
server.h
Normal file
37
server.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
#pragma once
|
||||
|
||||
/* Handles server operation. */
|
||||
|
||||
#include <common.h>
|
||||
#include <client.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int socket; /* server socket */
|
||||
struct sockaddr_in address; /* server address information */
|
||||
unsigned int port; /* server port in host byte order, practical reference */
|
||||
} server_t;
|
||||
|
||||
/**
|
||||
* Sets up the server on a specific port, binds to a socket and listens for
|
||||
* client connections.
|
||||
*
|
||||
* Returns:
|
||||
* - 0 on success,
|
||||
* - negative errno value set by an error in the setup process
|
||||
*/
|
||||
int server_setup(server_t *server, unsigned int port);
|
||||
|
||||
/**
|
||||
* Closes the server socket.
|
||||
*/
|
||||
void server_close(server_t *server);
|
||||
|
||||
/**
|
||||
* Accepts an incoming client connection.
|
||||
*
|
||||
* Returns:
|
||||
* - 0 on success,
|
||||
* - negative errno value set by an error in the process
|
||||
*/
|
||||
int server_accept(server_t *server, client_t *accepted_client);
|
Loading…
Add table
Add a link
Reference in a new issue