SeaBreeze
Socket.h
Go to the documentation of this file.
1 /***************************************************/
30 #ifndef SEABREEZE_SOCKET_H
31 #define SEABREEZE_SOCKET_H
32 
33 /* Includes */
34 #include "common/SeaBreeze.h"
40 #include <string>
41 
42 namespace seabreeze {
43 
44  class Socket {
45  public:
46  static Socket *create();
47 
48  virtual ~Socket();
49 
50  virtual void connect(Inet4Address &addr, int port)
52  virtual void connect(const std::string host, int port)
54 
55  virtual void close() throw (BusException) = 0;
56  virtual bool isClosed() = 0;
57  virtual bool isBound() = 0;
58 
59  /* Socket options */
60  virtual int getSOLinger() throw (SocketException) = 0;
61  virtual void setSOLinger(bool enable, int linger)
62  throw (SocketException) = 0;
63  virtual unsigned long getReadTimeoutMillis()
64  throw (SocketException) = 0;
65  virtual void setReadTimeoutMillis(unsigned long timeout)
66  throw (SocketException) = 0;
67 
68  /* Data transfer */
69  virtual int read(unsigned char *buffer, unsigned long length)
70  throw (BusTransferException) = 0;
71  virtual int write(const unsigned char *buffer, unsigned long length)
72  throw (BusTransferException) = 0;
73 
74  };
75 
76  /* Default implementation for (otherwise) pure virtual destructor */
77  inline Socket::~Socket() {}
78 }
79 
80 #endif /* SEABREEZE_SOCKET_H */
Definition: SocketException.h:37
Definition: BusTransferException.h:41
Definition: BusException.h:43
Definition: UnknownHostException.h:37
Definition: Inet4Address.h:44
Definition: Socket.h:44
Definition: BusConnectException.h:42
Encapsulates all SeaBreeze classes.
Definition: DeviceFactory.h:42