Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
e136d923
Commit
e136d923
authored
Sep 22, 2009
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZMQ-specific error codes added
parent
cc813689
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
64 additions
and
20 deletions
+64
-20
zmq.h
bindings/c/zmq.h
+28
-4
dispatcher.cpp
src/dispatcher.cpp
+1
-1
err.cpp
src/err.cpp
+5
-0
pub.cpp
src/pub.cpp
+1
-1
rep.cpp
src/rep.cpp
+3
-3
req.cpp
src/req.cpp
+4
-4
socket_base.cpp
src/socket_base.cpp
+5
-5
sub.cpp
src/sub.cpp
+2
-2
zmq.cpp
src/zmq.cpp
+15
-0
No files found.
bindings/c/zmq.h
View file @
e136d923
...
...
@@ -35,6 +35,21 @@ extern "C" {
#define ZMQ_EXPORT
#endif
////////////////////////////////////////////////////////////////////////////////
// 0MQ errors.
////////////////////////////////////////////////////////////////////////////////
// A number random anough not to collide with different errno ranges on
// different OSes. The assumption is that error_t is at least 32-bit type.
#define ZMQ_HAUSNUMERO 156384712
#define EMTHREAD (ZMQ_HAUSNUMERO + 1)
#define EFSM (ZMQ_HAUSNUMERO + 2)
#define ENOCOMPATPROTO (ZMQ_HAUSNUMERO + 3)
// Resolves system errors and 0MQ errors to human-readable string.
ZMQ_EXPORT
const
char
*
zmq_strerror
(
int
errnum
);
////////////////////////////////////////////////////////////////////////////////
// 0MQ message definition.
////////////////////////////////////////////////////////////////////////////////
...
...
@@ -154,7 +169,7 @@ ZMQ_EXPORT int zmq_term (void *context);
// Open a socket. 'type' is one of the socket types defined above.
//
// Errors: EINVAL - invalid socket type.
// EM
FILE
- the number of application threads entitled to hold open
// EM
THREAD
- the number of application threads entitled to hold open
// sockets at the same time was exceeded.
ZMQ_EXPORT
void
*
zmq_socket
(
void
*
context
,
int
type
);
...
...
@@ -276,9 +291,15 @@ ZMQ_EXPORT int zmq_setsockopt (void *s, int option, const void *optval,
// "udp://192.168.0.111;224.1.1.1:5555".
// Bind the socket to a particular address.
//
// Errors: EPROTONOSUPPORT - unsupported protocol.
// ENOCOMPATPROTO - protocol is not compatible with the socket type.
ZMQ_EXPORT
int
zmq_bind
(
void
*
s
,
const
char
*
addr
);
// Connect the socket to a particular address.
//
// Errors: EPROTONOSUPPORT - unsupported protocol.
// ENOCOMPATPROTO - protocol is not compatible with the socket type.
ZMQ_EXPORT
int
zmq_connect
(
void
*
s
,
const
char
*
addr
);
// Sending and receiving messages.
...
...
@@ -303,12 +324,14 @@ ZMQ_EXPORT int zmq_connect (void *s, const char *addr);
//
// Errors: EAGAIN - message cannot be sent at the moment (applies only to
// non-blocking send).
// EFAULT - function isn't supported by particular socket type.
// ENOTSUP - function isn't supported by particular socket type.
// EFSM - function cannot be called at the moment.
ZMQ_EXPORT
int
zmq_send
(
void
*
s
,
struct
zmq_msg_t
*
msg
,
int
flags
);
// Flush the messages that were send using ZMQ_NOFLUSH flag down the stream.
//
// Errors: FAULT - function isn't supported by particular socket type.
// Errors: ENOTSUP - function isn't supported by particular socket type.
// EFSM - function cannot be called at the moment.
ZMQ_EXPORT
int
zmq_flush
(
void
*
s
);
// Send a message from the socket 's'. 'flags' argument can be combination
...
...
@@ -316,7 +339,8 @@ ZMQ_EXPORT int zmq_flush (void *s);
//
// Errors: EAGAIN - message cannot be received at the moment (applies only to
// non-blocking receive).
// EFAULT - function isn't supported by particular socket type.
// ENOTSUP - function isn't supported by particular socket type.
// EFSM - function cannot be called at the moment.
ZMQ_EXPORT
int
zmq_recv
(
void
*
s
,
struct
zmq_msg_t
*
msg
,
int
flags
);
////////////////////////////////////////////////////////////////////////////////
...
...
src/dispatcher.cpp
View file @
e136d923
...
...
@@ -163,7 +163,7 @@ zmq::app_thread_t *zmq::dispatcher_t::choose_app_thread ()
return
app_threads
[
i
];
// Thread limit was exceeded.
errno
=
EM
FILE
;
errno
=
EM
THREAD
;
return
NULL
;
}
...
...
src/err.cpp
View file @
e136d923
...
...
@@ -24,11 +24,16 @@
const
char
*
zmq
::
wsa_error
()
{
int
errcode
=
WSAGetLastError
();
// TODO: This is not a generic way to handle this...
if
(
errcode
==
WSAEWOULDBLOCK
)
return
NULL
;
// TODO: It seems that list of Windows socket errors is longer than this.
// Investigate whether there's a way to convert it into the string
// automatically (wsaError->HRESULT->string?).
return
(
errcode
==
WSABASEERR
)
?
"No Error"
:
...
...
src/pub.cpp
View file @
e136d923
...
...
@@ -152,7 +152,7 @@ int zmq::pub_t::xflush ()
int
zmq
::
pub_t
::
xrecv
(
struct
zmq_msg_t
*
msg_
,
int
flags_
)
{
errno
=
E
FAULT
;
errno
=
E
NOTSUP
;
return
-
1
;
}
src/rep.cpp
View file @
e136d923
...
...
@@ -137,7 +137,7 @@ int zmq::rep_t::xsetsockopt (int option_, const void *optval_,
int
zmq
::
rep_t
::
xsend
(
struct
zmq_msg_t
*
msg_
,
int
flags_
)
{
if
(
!
waiting_for_reply
)
{
errno
=
EF
AULT
;
errno
=
EF
SM
;
return
-
1
;
}
...
...
@@ -161,7 +161,7 @@ int zmq::rep_t::xsend (struct zmq_msg_t *msg_, int flags_)
int
zmq
::
rep_t
::
xflush
()
{
errno
=
E
FAULT
;
errno
=
E
NOTSUP
;
return
-
1
;
}
...
...
@@ -171,7 +171,7 @@ int zmq::rep_t::xrecv (struct zmq_msg_t *msg_, int flags_)
zmq_msg_close
(
msg_
);
if
(
waiting_for_reply
)
{
errno
=
EF
AULT
;
errno
=
EF
SM
;
return
-
1
;
}
...
...
src/req.cpp
View file @
e136d923
...
...
@@ -120,12 +120,12 @@ int zmq::req_t::xsend (struct zmq_msg_t *msg_, int flags_)
// If we've sent a request and we still haven't got the reply,
// we can't send another request.
if
(
waiting_for_reply
)
{
errno
=
EF
AULT
;
errno
=
EF
SM
;
return
-
1
;
}
if
(
out_pipes
.
empty
())
{
errno
=
E
FAULT
;
errno
=
E
AGAIN
;
return
-
1
;
}
...
...
@@ -166,7 +166,7 @@ int zmq::req_t::xsend (struct zmq_msg_t *msg_, int flags_)
int
zmq
::
req_t
::
xflush
()
{
errno
=
E
FAULT
;
errno
=
E
NOTSUP
;
return
-
1
;
}
...
...
@@ -178,7 +178,7 @@ int zmq::req_t::xrecv (struct zmq_msg_t *msg_, int flags_)
// If request wasn't send, we can't wait for reply.
if
(
!
waiting_for_reply
)
{
zmq_msg_init
(
msg_
);
errno
=
EF
AULT
;
errno
=
EF
SM
;
return
-
1
;
}
...
...
src/socket_base.cpp
View file @
e136d923
...
...
@@ -100,8 +100,8 @@ int zmq::socket_base_t::bind (const char *addr_)
}
#endif
// Unknown
address type
.
errno
=
E
FAUL
T
;
// Unknown
protocol
.
errno
=
E
PROTONOSUPPOR
T
;
return
-
1
;
}
...
...
@@ -185,7 +185,7 @@ int zmq::socket_base_t::connect (const char *addr_)
// If the socket type requires bi-directional communication
// multicast is not an option (it is uni-directional).
if
(
options
.
requires_in
&&
options
.
requires_out
)
{
errno
=
E
FAULT
;
errno
=
E
NOCOMPATPROTO
;
return
-
1
;
}
...
...
@@ -235,8 +235,8 @@ int zmq::socket_base_t::connect (const char *addr_)
}
#endif
// Unknown
address type
.
errno
=
E
FAUL
T
;
// Unknown
protoco
.
errno
=
E
PROTONOSUPPOR
T
;
return
-
1
;
}
...
...
src/sub.cpp
View file @
e136d923
...
...
@@ -124,13 +124,13 @@ int zmq::sub_t::xsetsockopt (int option_, const void *optval_,
int
zmq
::
sub_t
::
xsend
(
struct
zmq_msg_t
*
msg_
,
int
flags_
)
{
errno
=
E
FAULT
;
errno
=
E
NOTSUP
;
return
-
1
;
}
int
zmq
::
sub_t
::
xflush
()
{
errno
=
E
FAULT
;
errno
=
E
NOTSUP
;
return
-
1
;
}
...
...
src/zmq.cpp
View file @
e136d923
...
...
@@ -19,6 +19,7 @@
#include "../bindings/c/zmq.h"
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <new>
...
...
@@ -35,6 +36,20 @@
#include <sys/time.h>
#endif
const
char
*
zmq_strerror
(
int
errnum_
)
{
switch
(
errnum_
)
{
case
EMTHREAD
:
return
"Number of preallocated application threads exceeded"
;
case
EFSM
:
return
"Operation cannot be accomplished in current state"
;
case
ENOCOMPATPROTO
:
return
"The protocol is not compatible with the socket type"
;
default:
return
strerror
(
errnum_
);
}
}
int
zmq_msg_init
(
zmq_msg_t
*
msg_
)
{
msg_
->
content
=
(
zmq
::
msg_content_t
*
)
ZMQ_VSM
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment