ESA JPIP server  0.1
client_info.h
Go to the documentation of this file.
1 #ifndef _CLIENT_INFO_H_
2 #define _CLIENT_INFO_H_
3 
4 
5 #include <time.h>
6 
7 
12 {
13 private:
14  int sock_;
15  int base_id_;
16  time_t tm_start;
18  long bytes_sent_;
19 
20 public:
28  {
29  sock_ = sock;
30  bytes_sent_ = 0;
31  base_id_ = base_id;
32  tm_start = ::time(NULL);
34  }
35 
39  int sock() const
40  {
41  return sock_;
42  }
43 
47  int base_id() const
48  {
49  return base_id_;
50  }
51 
55  int father_sock() const
56  {
57  return father_sock_;
58  }
59 
63  long bytes_sent() const
64  {
65  return bytes_sent_;
66  }
67 
72  long time() const
73  {
74  time_t now = ::time(NULL);
75  return (long)(tm_start - now);
76  }
77 
78  virtual ~ClientInfo()
79  {
80  }
81 };
82 
83 
84 #endif /* _CLIENT_INFO_H_ */
long bytes_sent() const
Returns the total bytes sent.
Definition: client_info.h:63
int sock_
Client socket.
Definition: client_info.h:14
int father_sock() const
Returns the father socket.
Definition: client_info.h:55
long time() const
Returns the time spent from the starting of the connection.
Definition: client_info.h:72
Contains information of a connected client.
Definition: client_info.h:11
int base_id_
Base identifier.
Definition: client_info.h:15
int father_sock_
Father socket.
Definition: client_info.h:17
int sock() const
Returns the client socket.
Definition: client_info.h:39
int base_id() const
Returns the base identifier.
Definition: client_info.h:47
long bytes_sent_
Total bytes sent.
Definition: client_info.h:18
time_t tm_start
When the connection started.
Definition: client_info.h:16
virtual ~ClientInfo()
Definition: client_info.h:78
ClientInfo(int base_id, int sock, int father_sock)
Initializes the object.
Definition: client_info.h:27