Explain number of allowed connections
This commit is contained in:
parent
b934bb120c
commit
9703b42b3a
3 changed files with 7 additions and 3 deletions
|
@ -13,7 +13,7 @@
|
|||
|
||||
/* Global variables used throughout the application. */
|
||||
server_t server; /* main server */
|
||||
client_t client; /* connected client */ //TODO working with only 1 client, this can be expanded into a list
|
||||
client_t client; /* connected client */
|
||||
client_t new_client; /* reserved for a new client request */
|
||||
tty_t tty_dev; /* connected tty device */
|
||||
|
||||
|
|
4
server.c
4
server.c
|
@ -52,8 +52,8 @@ int server_setup(server_t *server, unsigned int port)
|
|||
server->port = port;
|
||||
fprintf(stderr,"[%s] assigned port %u\n", __func__, server->port); // ntohs(server->address.sin_port)
|
||||
|
||||
/* listen for a client connection, allow some connections in queue */
|
||||
if (listen(server->socket, 1) == -1)
|
||||
/* listen for a client connection, allow (max-1) connections in queue */
|
||||
if (listen(server->socket, (SERVER_MAX_CONNECTIONS - 1)) == -1)
|
||||
{
|
||||
fprintf(stderr, "[%s:%d] error %d: %s\n", __func__, __LINE__,
|
||||
errno, strerror(errno));
|
||||
|
|
4
server.h
4
server.h
|
@ -5,6 +5,10 @@
|
|||
#include <common.h>
|
||||
#include <client.h>
|
||||
|
||||
/* The serial-server scenario makes sense only for 1 connected client.
|
||||
* Allow 1 extra connection to reject new clients with an explanation. */
|
||||
#define SERVER_MAX_CONNECTIONS 2
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int socket; /* server socket */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue