socket_streams.hpp
Go to the documentation of this file.
00001 
00010 /*****************************************************************************
00011 ** Ifdefs
00012 *****************************************************************************/
00013 
00014 #ifndef ECL_STREAMS_SOCKET_STREAMS_HPP_
00015 #define ECL_STREAMS_SOCKET_STREAMS_HPP_
00016 
00017 #ifdef ECL_IS_POSIX
00018 
00019 /*****************************************************************************
00020 ** Includes
00021 *****************************************************************************/
00022 
00023 #include <string>
00024 #include <ecl/config/macros.hpp>
00025 #include <ecl/devices/socket.hpp>
00026 #include <ecl/exceptions/standard_exception.hpp>
00027 #include "text_stream.hpp"
00028 #include "macros.hpp"
00029 
00030 /*****************************************************************************
00031 ** Namespaces
00032 *****************************************************************************/
00033 
00034 namespace ecl {
00035 
00036 /*****************************************************************************
00037 ** Interfaces [SocketClientStream]
00038 *****************************************************************************/
00047 class ecl_streams_PUBLIC SocketClientStream : public TextStream<SocketClient> {
00048 public:
00055         SocketClientStream() {};
00056 
00068         SocketClientStream(const std::string &host_name, const unsigned int &port_number) ecl_throw_decl(StandardException) {
00069                 ecl_try {
00070                         if ( !this->device().open(host_name, port_number) ) {
00071                                 error = this->device().error();
00072                         }
00073                 } ecl_catch(StandardException &e) {
00074                         ecl_throw(StandardException(LOC,e));
00075                 }
00076         }
00077 
00078         virtual ~SocketClientStream() {};
00079 };
00080 
00081 /*****************************************************************************
00082 ** Interfaces [SocketClientStream]
00083 *****************************************************************************/
00092 class ecl_streams_PUBLIC SocketServerStream : public TextStream<SocketServer> {
00093 public:
00100         SocketServerStream() {};
00101 
00112         SocketServerStream(const unsigned int &port_number) throw(StandardException) {
00113                 try {
00114                         this->device().open(port_number);
00115                 } catch(StandardException &e) {
00116                         throw StandardException(LOC,e);
00117                 }
00118         }
00119 
00120         virtual ~SocketServerStream() {};
00121 };
00122 
00123 } // namespace ecl
00124 
00125 #endif /* ECL_IS_POSIX */
00126 
00127 #endif /* ECL_STREAMS_SOCKET_STREAMS_HPP_ */


ecl_streams
Author(s): Daniel Stonier
autogenerated on Sun Oct 5 2014 23:36:00