socket_streams.hpp
Go to the documentation of this file.
1 
10 /*****************************************************************************
11 ** Ifdefs
12 *****************************************************************************/
13 
14 #ifndef ECL_STREAMS_SOCKET_STREAMS_HPP_
15 #define ECL_STREAMS_SOCKET_STREAMS_HPP_
16 
17 #ifdef ECL_IS_POSIX
18 
19 /*****************************************************************************
20 ** Includes
21 *****************************************************************************/
22 
23 #include <string>
24 #include <ecl/config/macros.hpp>
25 #include <ecl/devices/socket.hpp>
27 #include "text_stream.hpp"
28 #include "macros.hpp"
29 
30 /*****************************************************************************
31 ** Namespaces
32 *****************************************************************************/
33 
34 namespace ecl {
35 
36 /*****************************************************************************
37 ** Interfaces [SocketClientStream]
38 *****************************************************************************/
47 class ecl_streams_PUBLIC SocketClientStream : public TextStream<SocketClient> {
48 public:
55  SocketClientStream() {};
56 
68  SocketClientStream(const std::string &host_name, const unsigned int &port_number) ecl_throw_decl(StandardException) {
69  ecl_try {
70  if ( !this->device().open(host_name, port_number) ) {
71  error = this->device().error();
72  }
73  } ecl_catch(StandardException &e) {
74  ecl_throw(StandardException(LOC,e));
75  }
76  }
77 
78  virtual ~SocketClientStream() {};
79 };
80 
81 /*****************************************************************************
82 ** Interfaces [SocketClientStream]
83 *****************************************************************************/
92 class ecl_streams_PUBLIC SocketServerStream : public TextStream<SocketServer> {
93 public:
100  SocketServerStream() {};
101 
112  SocketServerStream(const unsigned int &port_number) throw(StandardException) {
113  try {
114  this->device().open(port_number);
115  } catch(StandardException &e) {
116  throw StandardException(LOC,e);
117  }
118  }
119 
120  virtual ~SocketServerStream() {};
121 };
122 
123 } // namespace ecl
124 
125 #endif /* ECL_IS_POSIX */
126 
127 #endif /* ECL_STREAMS_SOCKET_STREAMS_HPP_ */
#define ecl_throw(exception)
#define ecl_throw_decl(exception)
#define ecl_streams_PUBLIC
Definition: macros.hpp:37
Convenience header for various text streams.
#define ecl_catch(exception)
#define ecl_try


ecl_streams
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:50