iodrivers_base
TCPDriver.hpp
Go to the documentation of this file.
1 #include <iodrivers_base/Driver.hpp>
2 #include <netinet/in.h>
3 
4 namespace iodrivers_base{
5 
14  public:
15 
16  TCPDriver(int max_packet_size, bool extract_last = false);
17  virtual ~TCPDriver();
18 
19 
25  void tcp_server_init(int port);
26 
30  virtual int readPacket(uint8_t* buffer, int bufsize);
31  virtual int readPacket(uint8_t* buffer, int bufsize, base::Time const& packet_timeout, base::Time const& first_byte_timeout);
32 
36  virtual bool writePacket(uint8_t const* buffer, int bufsize, base::Time const& timeout);
37 
38  bool hasOpenSocked() const{
39  return socked_fd;
40  }
41 
42  protected:
50  virtual void checkClientConnection();
51 
55  int socked_fd;
56 
57  /*
58  * this member could be also handled by the Driver class itsel, but not sure what the Driver do internally,
59  * so keep this member for know inside of this class
60  */
61  int client_fd;
62 
66  struct sockaddr_in cli_addr;
67 
71  socklen_t clilen;
72 
73 };
74 
75 
76 
77 };
Definition: Driver.hpp:69
virtual ~TCPDriver()
Definition: TCPDriver.cpp:27
bool hasOpenSocked() const
Definition: TCPDriver.hpp:38
int client_fd
Definition: TCPDriver.hpp:61
TCPDriver(int max_packet_size, bool extract_last=false)
Definition: TCPDriver.cpp:18
virtual void checkClientConnection()
Definition: TCPDriver.cpp:55
struct sockaddr_in cli_addr
Definition: TCPDriver.hpp:66
Definition: TCPDriver.hpp:13
virtual int readPacket(uint8_t *buffer, int bufsize)
Definition: TCPDriver.cpp:66
int socked_fd
Definition: TCPDriver.hpp:55
virtual bool writePacket(uint8_t const *buffer, int bufsize, base::Time const &timeout)
Definition: TCPDriver.cpp:94
void tcp_server_init(int port)
Definition: TCPDriver.cpp:34
socklen_t clilen
Definition: TCPDriver.hpp:71