forked from ha7ilm/csdr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nmux.h
45 lines (40 loc) · 984 Bytes
/
nmux.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <errno.h>
#include <fcntl.h>
#include <poll.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include "tsmpool.h"
#define MSG_START "nmux: "
#define NMUX_DEBUG 0
typedef enum client_status_e
{
CS_CREATED,
CS_THREAD_RUNNING,
CS_THREAD_FINISHED
} client_status_t;
typedef struct client_s
{
struct sockaddr_in addr;
int socket;
int error; //set to non-zero on error (data transfer failed)
pthread_t thread;
tsmthread_t* tsmthread;
client_status_t status;
//the following members are there to give access to some global variables inside the thread:
tsmpool* lpool;
int sleeping;
} client_t;
void print_exit(const char* why);
void sig_handler(int signo);
void* client_thread (void* param);
void error_exit(const char* why);
void maxfd(int* maxfd, int fd);
int set_nonblocking(int fd);