-
Notifications
You must be signed in to change notification settings - Fork 112
/
ZError.cs
236 lines (217 loc) · 4.56 KB
/
ZError.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
namespace ZeroMQ
{
using lib;
public class ZError : ZSymbol
{
static ZError()
{
var one = ZSymbol.None;
}
internal static class Code
{
static Code()
{
Platform.SetupImplementation(typeof(Code));
}
private const int HAUSNUMERO = 156384712;
// TODO: find a way to make this independent of the Windows SDK version that libzmq was built against
// TODO: are all of these actually used by libzmq?
// these values are the Windows error codes as defined by the Windows 10 SDK when _CRT_NO_POSIX_ERROR_CODES is not defined
public static readonly int
EPERM = 1,
ENOENT = 2,
ESRCH = 3,
EINTR = 4,
EIO = 5,
ENXIO = 6,
E2BIG = 7,
ENOEXEC = 8,
EBADF = 9,
ECHILD = 10,
EAGAIN = 11,
ENOMEM = 12,
EACCES = 13,
EFAULT = 14,
ENOTBLK = 15,
EBUSY = 16,
EEXIST = 17,
EXDEV = 18,
ENODEV = 19,
ENOTDIR = 20,
EISDIR = 21,
EINVAL = 22,
ENFILE = 23,
EMFILE = 24,
ENOTTY = 25,
ETXTBSY = 26,
EFBIG = 27,
ENOSPC = 28,
ESPIPE = 29,
EROFS = 30,
EMLINK = 31,
EPIPE = 32,
EDOM = 33,
ERANGE = 34, // 34
ENOTSUP = 129,
EPROTONOSUPPORT = 135,
ENOBUFS = 119,
ENETDOWN = 116,
EADDRINUSE = 100,
EADDRNOTAVAIL = 101,
ECONNREFUSED = 107,
EINPROGRESS = 112,
ENOTSOCK = 128,
EMSGSIZE = 115,
// as of here are differences to nanomsg
EAFNOSUPPORT = 102,
ENETUNREACH = 118,
ECONNABORTED = 106,
ECONNRESET = 108,
ENOTCONN = 126,
ETIMEDOUT = 138,
EHOSTUNREACH = 110,
ENETRESET = 117,
/* Native ZeroMQ error codes. */
EFSM = HAUSNUMERO + 51,
ENOCOMPATPROTO = HAUSNUMERO + 52,
ETERM = HAUSNUMERO + 53,
EMTHREAD = HAUSNUMERO + 54
;
internal static class Posix
{
// source: http://www.virtsync.com/c-error-codes-include-errno
public static readonly int
// ENOTSUP = HAUSNUMERO + 1,
EPROTONOSUPPORT = 93,
ENOBUFS = 105,
ENETDOWN = 100,
EADDRINUSE = 98,
EADDRNOTAVAIL = 99,
ECONNREFUSED = 111,
EINPROGRESS = 115,
ENOTSOCK = 88,
EMSGSIZE = 90,
EAFNOSUPPORT = 97,
ENETUNREACH = 101,
ECONNABORTED = 103,
ECONNRESET = 104,
ENOTCONN = 107,
ETIMEDOUT = 110,
EHOSTUNREACH = 113,
ENETRESET = 102
;
}
internal static class MacOSX
{
public static readonly int
EAGAIN = 35,
EINPROGRESS = 36,
ENOTSOCK = 38,
EMSGSIZE = 40,
EPROTONOSUPPORT = 43,
EAFNOSUPPORT = 47,
EADDRINUSE = 48,
EADDRNOTAVAIL = 49,
ENETDOWN = 50,
ENETUNREACH = 51,
ENETRESET = 52,
ECONNABORTED = 53,
ECONNRESET = 54,
ENOBUFS = 55,
ENOTCONN = 57,
ETIMEDOUT = 60,
EHOSTUNREACH = 65
;
}
}
public static ZError GetLastErr()
{
int errno = zmq.errno();
return FromErrno(errno);
}
public static ZError FromErrno(int num)
{
// TODO: this can be made more efficient
ZError symbol = Find("E", num).OfType<ZError>().FirstOrDefault();
if (symbol != null) return symbol;
// unexpected error
return new ZError(num);
}
internal ZError(int errno)
: base(errno)
{ }
public static new ZError None
{
get
{
return default(ZError); // null
}
}
public static ZError
// DEFAULT = new ZmqError(0),
EPERM,
ENOENT,
ESRCH,
EINTR,
EIO,
ENXIO,
E2BIG,
ENOEXEC,
EBADF,
ECHILD,
EAGAIN,
ENOMEM,
EACCES,
EFAULT,
ENOTBLK,
EBUSY,
EEXIST,
EXDEV,
ENODEV,
ENOTDIR,
EISDIR,
EINVAL,
ENFILE,
EMFILE,
ENOTTY,
ETXTBSY,
EFBIG,
ENOSPC,
ESPIPE,
EROFS,
EMLINK,
EPIPE,
EDOM,
ERANGE, // 34
ENOTSUP,
EPROTONOSUPPORT,
ENOBUFS,
ENETDOWN,
EADDRINUSE,
EADDRNOTAVAIL,
ECONNREFUSED,
EINPROGRESS,
ENOTSOCK,
EMSGSIZE,
// as of here are differences to nanomsg
EAFNOSUPPORT,
ENETUNREACH,
ECONNABORTED,
ECONNRESET,
ENOTCONN,
ETIMEDOUT,
EHOSTUNREACH,
ENETRESET,
/* Native ZeroMQ error codes. */
EFSM,
ENOCOMPATPROTO,
ETERM,
EMTHREAD // = HAUSNUMERO + 54
;
}
}