TCP Socket - C Language
|
00001 00014 #ifndef COMM_H 00015 #define COMM_H 00016 00017 #include <sys/types.h> 00018 #include <sys/socket.h> /* definitions of structures needed for sockets */ 00019 #include <netinet/in.h> /* constants and structures needed for internet domain addresses */ 00020 #include <sys/poll.h> /* poll(2) and related definitions. */ 00021 #include <string.h> 00022 #include <stdlib.h> 00023 #include <unistd.h> 00024 #include <netdb.h> 00025 00026 #include "msg.h" 00027 #include "errore.h" 00028 00029 /* ----= TIPI =---- */ 00030 00032 typedef struct { 00033 size_t skDim; 00034 struct pollfd *sk; 00035 } comm; 00036 00037 #define MAXCONN 20 00038 #define INVALID_DESC -1 00040 /* -= FUNZIONI =- */ 00041 00055 comm * newServerChannel(const char *service); 00056 00063 int acceptConnection(comm * srvComm); 00064 00071 int closeServerSocket(comm * srvComm); 00072 00083 int receiveMessage(int sc, message_t *msg); 00084 00092 int sendMessage(int sc, message_t *msg); 00093 00100 int closeConnection(int sc); 00101 00109 int retryConnection(const char* hostname, const char * service); 00110 00111 #endif