2016-09-16 00:09:04 +02:00
|
|
|
#ifndef __TCPDSERVER_H__
|
|
|
|
#define __TCPDSERVER_H__
|
|
|
|
|
2016-09-16 15:22:14 +02:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
2016-09-16 00:09:04 +02:00
|
|
|
|
2016-09-16 21:41:23 +02:00
|
|
|
typedef struct {
|
|
|
|
struct sockaddr_in c_sock;
|
|
|
|
int sfd;
|
2016-09-18 00:17:47 +02:00
|
|
|
char * fifoOut;
|
2016-09-16 21:41:23 +02:00
|
|
|
} p_data;
|
|
|
|
|
2016-09-16 00:09:04 +02:00
|
|
|
int initConnection ();
|
|
|
|
void endConnection (int sock, int csock);
|
2016-09-18 01:03:37 +02:00
|
|
|
|
2016-09-16 15:22:14 +02:00
|
|
|
void printClientAddr (struct sockaddr_in *csin);
|
2016-09-18 01:03:37 +02:00
|
|
|
|
2016-09-16 15:22:14 +02:00
|
|
|
void write_message(int sock, const char *buffer);
|
|
|
|
int read_message(int sock, char *buffer);
|
2016-09-18 01:03:37 +02:00
|
|
|
|
|
|
|
//2 threads for listen and send data
|
|
|
|
void * listen_thread(void * pdata);
|
|
|
|
void * send_thread(void * pdata);
|
|
|
|
|
|
|
|
//parse the first message from client in service and version
|
2016-09-18 00:17:47 +02:00
|
|
|
void parseServiceVersion(char * buf, char ** service, int *version);
|
2016-09-18 01:03:37 +02:00
|
|
|
|
|
|
|
//create 2 pathnames such as : pid-index-version-in/out
|
2016-09-16 21:41:23 +02:00
|
|
|
void inOutPathCreate(char ** pathname, int version);
|
2016-09-18 01:03:37 +02:00
|
|
|
|
|
|
|
//create a fifo file
|
2016-09-16 21:41:23 +02:00
|
|
|
int fifo_create (char * path);
|
2016-09-16 00:09:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|