36 #if defined ZMQ_HAVE_WINDOWS 38 return "Not supported";
40 return "Protocol not supported";
42 return "No buffer space available";
44 return "Network is down";
46 return "Address in use";
48 return "Address not available";
50 return "Connection refused";
52 return "Operation in progress";
55 return "Operation cannot be accomplished in current state";
57 return "The protocol is not compatible with the socket type";
59 return "Context was terminated";
61 return "No thread available";
64 #pragma warning (push) 65 #pragma warning (disable:4996) 67 return strerror (errno_);
76 #if defined ZMQ_HAVE_WINDOWS 79 ULONG_PTR extra_info [1];
80 extra_info [0] = (ULONG_PTR) errmsg_;
81 RaiseException (0x40000015, EXCEPTION_NONCONTINUABLE, 1, extra_info);
89 #ifdef ZMQ_HAVE_WINDOWS 91 const char *zmq::wsa_error()
93 const int last_error = WSAGetLastError();
95 if (last_error == WSAEWOULDBLOCK)
98 return wsa_error_no (last_error);
101 const char *zmq::wsa_error_no (
int no_)
107 (no_ == WSABASEERR) ?
110 "Interrupted system call" :
114 "Permission denied" :
120 "Too many open files" :
121 (no_ == WSAEWOULDBLOCK) ?
122 "Operation would block" :
123 (no_ == WSAEINPROGRESS) ?
124 "Operation now in progress" :
125 (no_ == WSAEALREADY) ?
126 "Operation already in progress" :
127 (no_ == WSAENOTSOCK) ?
128 "Socket operation on non-socket" :
129 (no_ == WSAEDESTADDRREQ) ?
130 "Destination address required" :
131 (no_ == WSAEMSGSIZE) ?
133 (no_ == WSAEPROTOTYPE) ?
134 "Protocol wrong type for socket" :
135 (no_ == WSAENOPROTOOPT) ?
136 "Bad protocol option" :
137 (no_ == WSAEPROTONOSUPPORT) ?
138 "Protocol not supported" :
139 (no_ == WSAESOCKTNOSUPPORT) ?
140 "Socket type not supported" :
141 (no_ == WSAEOPNOTSUPP) ?
142 "Operation not supported on socket" :
143 (no_ == WSAEPFNOSUPPORT) ?
144 "Protocol family not supported" :
145 (no_ == WSAEAFNOSUPPORT) ?
146 "Address family not supported by protocol family" :
147 (no_ == WSAEADDRINUSE) ?
148 "Address already in use" :
149 (no_ == WSAEADDRNOTAVAIL) ?
150 "Can't assign requested address" :
151 (no_ == WSAENETDOWN) ?
153 (no_ == WSAENETUNREACH) ?
154 "Network is unreachable" :
155 (no_ == WSAENETRESET) ?
156 "Net dropped connection or reset" :
157 (no_ == WSAECONNABORTED) ?
158 "Software caused connection abort" :
159 (no_ == WSAECONNRESET) ?
160 "Connection reset by peer" :
161 (no_ == WSAENOBUFS) ?
162 "No buffer space available" :
163 (no_ == WSAEISCONN) ?
164 "Socket is already connected" :
165 (no_ == WSAENOTCONN) ?
166 "Socket is not connected" :
167 (no_ == WSAESHUTDOWN) ?
168 "Can't send after socket shutdown" :
169 (no_ == WSAETOOMANYREFS) ?
170 "Too many references can't splice" :
171 (no_ == WSAETIMEDOUT) ?
172 "Connection timed out" :
173 (no_ == WSAECONNREFUSED) ?
174 "Connection refused" :
176 "Too many levels of symbolic links" :
177 (no_ == WSAENAMETOOLONG) ?
178 "File name too long" :
179 (no_ == WSAEHOSTDOWN) ?
181 (no_ == WSAEHOSTUNREACH) ?
183 (no_ == WSAENOTEMPTY) ?
184 "Directory not empty" :
185 (no_ == WSAEPROCLIM) ?
186 "Too many processes" :
190 "Disc Quota Exceeded" :
192 "Stale NFS file handle" :
193 (no_ == WSAEREMOTE) ?
194 "Too many levels of remote in path" :
195 (no_ == WSASYSNOTREADY) ?
196 "Network SubSystem is unavailable" :
197 (no_ == WSAVERNOTSUPPORTED) ?
198 "WINSOCK DLL Version out of range" :
199 (no_ == WSANOTINITIALISED) ?
200 "Successful WSASTARTUP not yet performed" :
201 (no_ == WSAHOST_NOT_FOUND) ?
203 (no_ == WSATRY_AGAIN) ?
204 "Non-Authoritative Host not found" :
205 (no_ == WSANO_RECOVERY) ?
206 "Non-Recoverable errors: FORMERR REFUSED NOTIMP" :
207 (no_ == WSANO_DATA) ?
208 "Valid name no data record of requested" :
212 void zmq::win_error (
char *buffer_,
size_t buffer_size_)
214 DWORD errcode = GetLastError ();
215 #if defined _WIN32_WCE 216 DWORD rc = FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM |
217 FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errcode, MAKELANGID(LANG_NEUTRAL,
218 SUBLANG_DEFAULT), (LPWSTR)buffer_, buffer_size_ /
sizeof(
wchar_t), NULL);
220 DWORD rc = FormatMessageA (FORMAT_MESSAGE_FROM_SYSTEM |
221 FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errcode, MAKELANGID(LANG_NEUTRAL,
222 SUBLANG_DEFAULT), buffer_, (DWORD) buffer_size_, NULL);
227 int zmq::wsa_error_to_errno (
int errcode)
261 case WSAEDESTADDRREQ:
273 case WSAEPROTONOSUPPORT:
276 case WSAESOCKTNOSUPPORT:
282 case WSAEPFNOSUPPORT:
285 case WSAEAFNOSUPPORT:
291 case WSAEADDRNOTAVAIL:
303 case WSAECONNABORTED:
321 case WSAETOOMANYREFS:
327 case WSAECONNREFUSED:
333 case WSAENAMETOOLONG:
339 case WSAEHOSTUNREACH:
363 case WSAVERNOTSUPPORTED:
366 case WSANOTINITIALISED:
369 case WSAHOST_NOT_FOUND:
389 #ifdef HAVE_LIBUNWIND 391 #define UNW_LOCAL_ONLY 392 #include <libunwind.h> 401 unsigned frame_n = 0;
403 unw_getcontext (&ctx);
404 unw_init_local (&cursor, &ctx);
406 while (unw_step (&cursor) > 0) {
408 unw_proc_info_t p_info;
409 const char *file_name;
410 char *demangled_name;
411 char func_name[256] =
"";
415 if (unw_get_proc_info (&cursor, &p_info))
418 addr = (
void *)(p_info.start_ip + offset);
420 if (dladdr (addr, &dl_info) && dl_info.dli_fname)
421 file_name = dl_info.dli_fname;
425 rc = unw_get_proc_name (&cursor, func_name, 256, &offset);
426 if (rc == -UNW_ENOINFO)
427 strcpy(func_name,
"?");
429 demangled_name = abi::__cxa_demangle (func_name, NULL, NULL, &rc);
431 printf (
"#%u %p in %s (%s+0x%lx)\n", frame_n++, addr, file_name,
432 rc ? func_name : demangled_name, (
unsigned long) offset);
433 free (demangled_name);
void zmq_abort(const char *errmsg_)
void print_backtrace(void)
const char * errno_to_string(int errno_)