Main Page
Namespaces
Classes
Files
File List
File Members
include
ecl
devices
detail
socket_error_handler_pos.hpp
Go to the documentation of this file.
1
8
/*****************************************************************************
9
** Ifdefs
10
*****************************************************************************/
11
12
#ifndef ECL_DEVICES_SOCKET_ERROR_HANDLER_POS_HPP_
13
#define ECL_DEVICES_SOCKET_ERROR_HANDLER_POS_HPP_
14
15
/*****************************************************************************
16
** Cross platform
17
*****************************************************************************/
18
19
#include <ecl/config/ecl.hpp>
20
#ifndef ECL_IS_APPLE
21
#ifdef ECL_IS_POSIX
22
23
/*****************************************************************************
24
** Includes
25
*****************************************************************************/
26
27
#include <errno.h>
28
#include <string>
29
#include <
ecl/errors/handlers.hpp
>
30
#include <netdb.h>
// gethostbyname
31
32
/*****************************************************************************
33
** Namespaces
34
*****************************************************************************/
35
36
namespace
ecl
{
37
namespace
devices {
38
39
/*****************************************************************************
40
** Methods
41
*****************************************************************************/
47
inline
ecl::Error
socket_error() {
48
switch
( errno ) {
49
case
( EACCES ) :
return
ecl::Error
(
ecl::OpenError
);
50
case
( EAFNOSUPPORT):
return
ecl::Error
(
ecl::NotSupportedError
);
51
case
( EINVAL ) :
return
ecl::Error
(
ecl::InvalidArgError
);
52
case
( EMFILE ) :
return
ecl::Error
(
ecl::OutOfRangeError
);
53
case
( ENFILE ) :
return
ecl::Error
(
ecl::OutOfResourcesError
);
54
case
( ENOBUFS ) :
return
ecl::Error
(
ecl::MemoryError
);
55
case
( ENOMEM ) :
return
ecl::Error
(
ecl::MemoryError
);
56
case
( EPROTONOSUPPORT ) :
return
ecl::Error
(
ecl::NotSupportedError
);
57
default
:
return
ecl::Error
(
UnknownError
);
58
}
59
}
65
inline
ecl::Error
bind_error() {
66
switch
( errno ) {
67
case
( EACCES ) :
return
ecl::Error
(
ecl::PermissionsError
);
68
case
( EADDRINUSE ) :
return
ecl::Error
(
ecl::BusyError
);
69
case
( EBADF ) :
return
ecl::Error
(
ecl::InvalidObjectError
);
70
case
( EINVAL ) :
return
ecl::Error
(
ecl::BusyError
);
71
case
( ENOTSOCK ) :
return
ecl::Error
(
ecl::InvalidObjectError
);
72
case
( EADDRNOTAVAIL ) :
return
ecl::Error
(
ecl::InvalidObjectError
);
73
case
( EFAULT ) :
return
ecl::Error
(
ecl::OutOfRangeError
);
74
case
( ELOOP ) :
return
ecl::Error
(
ecl::SystemFailureError
);
75
case
( ENAMETOOLONG ) :
return
ecl::Error
(
ecl::InvalidArgError
);
76
case
( ENOENT ) :
return
ecl::Error
(
ecl::InvalidObjectError
);
77
case
( ENOMEM ) :
return
ecl::Error
(
ecl::MemoryError
);
78
case
( ENOTDIR ) :
return
ecl::Error
(
ecl::InvalidArgError
);
79
case
( EROFS ) :
return
ecl::Error
(
ecl::PermissionsError
);
80
default
:
return
ecl::Error
(
UnknownError
);
81
}
82
}
88
inline
ecl::Error
accept_error() {
89
switch
( errno ) {
90
case
( EWOULDBLOCK ) :
return
ecl::Error
(
ecl::BlockingError
);
91
case
( EBADF ) :
return
ecl::Error
(
ecl::InvalidObjectError
);
92
case
( ECONNABORTED ):
return
ecl::Error
(
ecl::InterruptedError
);
93
case
( EINTR ) :
return
ecl::Error
(
ecl::InterruptedError
);
94
case
( EINVAL ) :
return
ecl::Error
(
ecl::UsageError
);
95
case
( EMFILE ) :
return
ecl::Error
(
ecl::OutOfResourcesError
);
96
case
( ENFILE ) :
return
ecl::Error
(
ecl::OutOfResourcesError
);
97
case
( ENOTSOCK ) :
return
ecl::Error
(
ecl::InvalidObjectError
);
98
case
( EOPNOTSUPP ) :
return
ecl::Error
(
ecl::InvalidObjectError
);
99
case
( EFAULT ) :
return
ecl::Error
(
ecl::PermissionsError
);
100
case
( ENOBUFS ) :
return
ecl::Error
(
ecl::MemoryError
);
101
case
( ENOMEM ) :
return
ecl::Error
(
ecl::MemoryError
);
102
case
( EPROTO ) :
return
ecl::Error
(
ecl::InvalidArgError
);
103
case
( EPERM ) :
return
ecl::Error
(
ecl::PermissionsError
);
104
default
:
return
ecl::Error
(
UnknownError
);
105
}
106
}
112
inline
ecl::Error
receive_error() {
113
114
switch
( errno ) {
115
case
( EAGAIN || EWOULDBLOCK ) :
return
ecl::Error
(
ecl::InterruptedError
);
116
case
( EBADF ) :
return
ecl::Error
(
ecl::InvalidObjectError
);
117
case
( ECONNREFUSED) :
return
ecl::Error
(
ecl::ConnectionError
);
118
case
( EFAULT ) :
return
ecl::Error
(
ecl::SystemFailureError
);
119
case
( EINTR ) :
return
ecl::Error
(
ecl::InterruptedError
);
120
case
( EINVAL ) :
return
ecl::Error
(
ecl::InvalidArgError
);
121
case
( ENOMEM ) :
return
ecl::Error
(
ecl::MemoryError
);
122
case
( ENOTCONN ) :
return
ecl::Error
(
ecl::ConnectionError
);
123
case
( ENOTSOCK ) :
return
ecl::Error
(
ecl::InvalidObjectError
);
124
default
:
return
ecl::Error
(
UnknownError
);
125
}
126
}
132
inline
ecl::Error
ioctl_error() {
133
134
switch
( errno ) {
135
case
( EBADF ) :
return
ecl::Error
(
ecl::InvalidObjectError
);
136
case
( EFAULT ) :
return
ecl::Error
(
ecl::OutOfRangeError
);
137
case
( EINVAL ) :
return
ecl::Error
(
ecl::InvalidArgError
);
138
case
( ENOTTY ) :
return
ecl::Error
(
ecl::InvalidObjectError
);
139
default
:
return
ecl::Error
(
UnknownError
);
140
}
141
}
142
148
inline
ecl::Error
send_error() {
149
150
switch
( errno ) {
151
case
( EAGAIN || EWOULDBLOCK ) :
return
ecl::Error
(
ecl::BlockingError
);
152
case
( EWOULDBLOCK ) :
return
ecl::Error
(
ecl::BlockingError
);
153
case
( EACCES ) :
return
ecl::Error
(
ecl::PermissionsError
);
154
case
( EBADF ) :
return
ecl::Error
(
ecl::InvalidObjectError
);
155
case
( ECONNRESET ) :
return
ecl::Error
(
ecl::InterruptedError
);
156
case
( EFAULT ) :
return
ecl::Error
(
ecl::SystemFailureError
);
157
case
( EINTR ) :
return
ecl::Error
(
ecl::InterruptedError
);
158
case
( EINVAL ) :
return
ecl::Error
(
ecl::InvalidArgError
);
159
case
( EISCONN ) :
return
ecl::Error
(
ecl::ConnectionError
);
160
case
( EMSGSIZE ) :
return
ecl::Error
(
ecl::WriteError
);
161
case
( ENOBUFS ) :
return
ecl::Error
(
ecl::OutOfResourcesError
);
162
case
( ENOMEM ) :
return
ecl::Error
(
ecl::MemoryError
);
163
case
( ENOTCONN ) :
return
ecl::Error
(
ecl::ConnectionError
);
164
case
( ENOTSOCK ) :
return
ecl::Error
(
ecl::InvalidObjectError
);
165
case
( EOPNOTSUPP ) :
return
ecl::Error
(
ecl::NotSupportedError
);
166
case
( EPIPE ) :
return
ecl::Error
(
ecl::InterruptedError
);
167
default
:
return
ecl::Error
(
UnknownError
);
168
}
169
}
170
176
inline
ecl::Error
gethostbyname_error() {
177
switch
( h_errno ) {
178
case
( HOST_NOT_FOUND ) :
return
ecl::Error
(
ecl::ConnectionError
);
179
case
( NO_ADDRESS ) :
return
ecl::Error
(
ecl::InvalidArgError
);
180
case
( NO_RECOVERY ) :
return
ecl::Error
(
ecl::UnknownError
);
181
default
:
return
ecl::Error
(
ecl::UnknownError
);
182
}
183
}
189
inline
ecl::Error
connection_error() {
190
switch
( errno ) {
191
case
( ( EACCES ) || ( EPERM ) ):
return
ecl::Error
(
ecl::PermissionsError
);
192
case
( EADDRINUSE ) :
return
ecl::Error
(
ecl::BusyError
);
193
case
( EAFNOSUPPORT ):
return
ecl::Error
(
ecl::NotSupportedError
);
194
case
( EAGAIN ) :
return
ecl::Error
(
ecl::OutOfResourcesError
);
195
case
( EALREADY ) :
return
ecl::Error
(
ecl::BlockingError
);
196
case
( EBADF ) :
return
ecl::Error
(
ecl::InvalidObjectError
);
197
case
( ECONNREFUSED ):
return
ecl::Error
(
ecl::ConnectionRefusedError
);
198
case
( EFAULT ) :
return
ecl::Error
(
ecl::OutOfRangeError
);
199
case
( EINPROGRESS ) :
return
ecl::Error
(
ecl::BlockingError
);
200
case
( EINTR ) :
return
ecl::Error
(
ecl::InterruptedError
);
201
case
( EISCONN ) :
return
ecl::Error
(
ecl::ConnectionError
);
202
case
( ENETUNREACH ) :
return
ecl::Error
(
ecl::ConfigurationError
);
203
case
( ENOTSOCK ) :
return
ecl::Error
(
ecl::InvalidObjectError
);
204
case
( ETIMEDOUT ) :
return
ecl::Error
(
ecl::TimeOutError
);
205
default
:
return
ecl::Error
(
ecl::UnknownError
);
206
}
207
}
208
209
}
// namespace devices
210
}
// namespace ecl
211
212
#endif
/* ECL_IS_POSIX */
213
#endif
/* !ECL_IS_APPLE */
214
#endif
/* ECL_DEVICES_SOCKET_ERROR_HANDLER_POS_HPP_ */
ecl
Embedded control libraries.
ecl::InvalidObjectError
InvalidObjectError
ecl::InterruptedError
InterruptedError
ecl::PermissionsError
PermissionsError
ecl::InvalidArgError
InvalidArgError
ecl::NotSupportedError
NotSupportedError
ecl::UnknownError
UnknownError
ecl::ConfigurationError
ConfigurationError
ecl::Error
ecl::OutOfRangeError
OutOfRangeError
ecl::WriteError
WriteError
ecl::BlockingError
BlockingError
ecl::OpenError
OpenError
ecl::ConnectionError
ConnectionError
ecl::OutOfResourcesError
OutOfResourcesError
ecl::BusyError
BusyError
ecl::UsageError
UsageError
handlers.hpp
ecl::TimeOutError
TimeOutError
ecl::SystemFailureError
SystemFailureError
ecl::MemoryError
MemoryError
ecl::ConnectionRefusedError
ConnectionRefusedError
ecl_devices
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:45