Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
include
ecl
streams
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>
26
#include <ecl/exceptions/standard_exception.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_ */
ecl
ecl_throw
#define ecl_throw(exception)
Standard ecl throw exception throw.
Definition:
ecl/exceptions/macros.hpp:74
ecl_throw_decl
#define ecl_throw_decl(exception)
Standard ecl throw exception declaration.
Definition:
ecl/exceptions/macros.hpp:64
LOC
#define LOC
Stringify the line of code you are at.
Definition:
ecl/errors/macros.hpp:67
text_stream.hpp
Convenience header for various text streams.
ecl_catch
#define ecl_catch(exception)
The catch part of a try-catch macro matching ecl_throw calls.
Definition:
ecl/exceptions/macros.hpp:86
ecl_streams_PUBLIC
#define ecl_streams_PUBLIC
Definition:
ecl/streams/macros.hpp:37
ecl_try
#define ecl_try
The try part of a try-catch macro matching ecl_throw calls.
Definition:
ecl/exceptions/macros.hpp:80
xbot_driver
Author(s): Roc, wangpeng@droid.ac.cn
autogenerated on Sat Oct 10 2020 03:27:38