PAASS
Software suite to Acquire and Analyze Data from Pixie16
poll2_socket.h
Go to the documentation of this file.
1 
15 #ifndef POLL2_SOCKET_H
16 #define POLL2_SOCKET_H
17 
18 #include <netinet/in.h>
19 
20 #define POLL2_SOCKET_VERSION "1.1.01"
21 #define POLL2_SOCKET_DATE "May 11th, 2015"
22 
23 class Server{
24  private:
25  int sock, length, n;
26  socklen_t fromlen;
27  struct sockaddr_in serv;
28  struct sockaddr_in from;
29  bool init;
30 
32  fd_set readfds, masterfds;
33  struct timeval timeout;
34 
35  public:
36  Server(){ init = false; }
37 
38  ~Server(){ Close(); }
39 
40  int Get(){ return sock; }
41 
43  bool Init(int port_, int sec_=10, int usec_=0);
44 
47  int RecvMessage(char *message_, size_t length_);
48 
51  int SendMessage(char *message_, size_t length_);
52 
53  bool Select(int &retval);
54 
56  void Close();
57 };
58 
59 class Client{
60  private:
61  int sock, n;
62  unsigned int length;
63  struct sockaddr_in serv, from;
64  struct hostent *hp;
65  bool init;
66 
67  public:
68  Client(){ init = false; }
69 
70  ~Client(){ Close(); }
71 
72  int Get(){ return sock; }
73 
76  bool Init(const char *address_, int port_);
77 
80  int RecvMessage(char *message_, size_t length_);
81 
84  int SendMessage(char *message_, size_t length_);
85 
87  void Close();
88 };
89 
90 #endif
int to_usec
Definition: poll2_socket.h:31
struct hostent * hp
Definition: poll2_socket.h:64
struct sockaddr_in serv
Definition: poll2_socket.h:27
fd_set masterfds
Definition: poll2_socket.h:32
void Close()
Close the socket.
unsigned int length
Definition: poll2_socket.h:62
int RecvMessage(char *message_, size_t length_)
struct sockaddr_in from
Definition: poll2_socket.h:28
int SendMessage(char *message_, size_t length_)
bool Select(int &retval)
bool init
Definition: poll2_socket.h:29
socklen_t fromlen
Definition: poll2_socket.h:26
int sock
Definition: poll2_socket.h:61
struct timeval timeout
Definition: poll2_socket.h:33
int Get()
Definition: poll2_socket.h:72
int sock
Definition: poll2_socket.h:25
int Get()
Definition: poll2_socket.h:40
bool Init(int port_, int sec_=10, int usec_=0)
Initialize the serv object and open a specified port. Returns false if the socket fails to open or th...
int length
Definition: poll2_socket.h:25
bool init
Definition: poll2_socket.h:65
fd_set readfds
Definition: poll2_socket.h:32
int to_sec
Definition: poll2_socket.h:31