socket.h
Go to the documentation of this file.
1 
26 #ifndef ODVA_ETHERNETIP_SOCKET_SOCKET_H
27 #define ODVA_ETHERNETIP_SOCKET_SOCKET_H
28 
29 #include <string>
30 #include <boost/asio.hpp>
31 
34 
35 using std::string;
36 using std::size_t;
37 using boost::asio::buffer;
38 using boost::asio::const_buffer;
39 using boost::asio::mutable_buffer;
40 
41 namespace eip {
42 
43 using serialization::Serializable;
44 using serialization::BufferWriter;
45 
46 namespace socket {
47 
52 class Socket
53 {
54 public:
55 
56  virtual ~Socket() { }
57 
63  virtual void open(string hostname, string port) = 0;
64 
68  virtual void close() = 0;
69 
75  virtual size_t send(const_buffer buf) = 0;
76 
82  virtual size_t send(const Serializable& msg)
83  {
84  std::vector<char> buf(msg.getLength());
85  BufferWriter writer(buffer(buf));
86  msg.serialize(writer);
87  return send(buffer(buf));
88  }
89 
95  virtual size_t receive(mutable_buffer buf) = 0;
96 
97 };
98 
99 } // namespace socket
100 } // namespace eip
101 #endif // ODVA_ETHERNETIP_SOCKET_SOCKET_H
virtual size_t receive(mutable_buffer buf)=0
virtual size_t send(const Serializable &msg)
Definition: socket.h:82
virtual size_t send(const_buffer buf)=0
Definition: connection.h:41
virtual ~Socket()
Definition: socket.h:56
virtual void close()=0
virtual void open(string hostname, string port)=0


odva_ethernetip
Author(s): Kareem Shehata
autogenerated on Mon Jun 10 2019 14:00:16