socket.h
Go to the documentation of this file.
00001 
00026 #ifndef ODVA_ETHERNETIP_SOCKET_SOCKET_H
00027 #define ODVA_ETHERNETIP_SOCKET_SOCKET_H
00028 
00029 #include <string>
00030 #include <boost/asio.hpp>
00031 
00032 #include "odva_ethernetip/serialization/serializable.h"
00033 #include "odva_ethernetip/serialization/buffer_writer.h"
00034 
00035 using std::string;
00036 using std::size_t;
00037 using boost::asio::buffer;
00038 using boost::asio::const_buffer;
00039 using boost::asio::mutable_buffer;
00040 
00041 namespace eip {
00042 
00043 using serialization::Serializable;
00044 using serialization::BufferWriter;
00045 
00046 namespace socket {
00047 
00052 class Socket
00053 {
00054 public:
00055 
00056   virtual ~Socket() { }
00057 
00063   virtual void open(string hostname, string port) = 0;
00064 
00068   virtual void close() = 0;
00069 
00075   virtual size_t send(const_buffer buf) = 0;
00076 
00082   virtual size_t send(const Serializable& msg)
00083   {
00084     std::vector<char> buf(msg.getLength());
00085     BufferWriter writer(buffer(buf));
00086     msg.serialize(writer);
00087     return send(buffer(buf));
00088   }
00089 
00095   virtual size_t receive(mutable_buffer buf) = 0;
00096 
00097 };
00098 
00099 } // namespace socket
00100 } // namespace eip
00101 #endif  // ODVA_ETHERNETIP_SOCKET_SOCKET_H


odva_ethernetip
Author(s): Kareem Shehata
autogenerated on Sat Jun 8 2019 20:21:23