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
5ef63318
Commit
5ef63318
authored
May 13, 2012
by
Pieter Hintjens
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #341 from kennytm/master
Allow the ZMQ_MONITOR code compilable on gcc 4.7 on Linux.
parents
89d5054e
c995de65
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
10 deletions
+15
-10
zmq_getsockopt.txt
doc/zmq_getsockopt.txt
+1
-1
options.cpp
src/options.cpp
+3
-3
session_base.cpp
src/session_base.cpp
+2
-0
test_monitor.cpp
tests/test_monitor.cpp
+9
-6
No files found.
doc/zmq_getsockopt.txt
View file @
5ef63318
...
@@ -456,7 +456,7 @@ Default value:: -1 (leave to OS default)
...
@@ -456,7 +456,7 @@ Default value:: -1 (leave to OS default)
Applicable socket types:: all, when using TCP transports.
Applicable socket types:: all, when using TCP transports.
ZMQ_MONITOR: Registers a callback for socket state changes
ZMQ_MONITOR: Registers a callback for socket state changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Registers a callback function / event sink for changes in underlying socket state.
Registers a callback function / event sink for changes in underlying socket state.
The default value of `NULL` means no monitor callback function.
The default value of `NULL` means no monitor callback function.
...
...
src/options.cpp
View file @
5ef63318
...
@@ -325,7 +325,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
...
@@ -325,7 +325,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
errno
=
EINVAL
;
errno
=
EINVAL
;
return
-
1
;
return
-
1
;
}
}
monitor
=
((
zmq_monitor_fn
*
)
optval_
);
monitor
=
*
((
zmq_monitor_fn
**
)
&
optval_
);
return
0
;
return
0
;
}
}
}
}
...
@@ -550,8 +550,8 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
...
@@ -550,8 +550,8 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
errno
=
EINVAL
;
errno
=
EINVAL
;
return
-
1
;
return
-
1
;
}
}
((
zmq_monitor_fn
*
)
optval_
)
=
monitor
;
*
((
zmq_monitor_fn
**
)
&
optval_
)
=
monitor
;
*
optvallen_
=
sizeof
(
void
*
);
*
optvallen_
=
sizeof
(
zmq_monitor_fn
*
);
return
0
;
return
0
;
}
}
...
...
src/session_base.cpp
View file @
5ef63318
...
@@ -20,6 +20,8 @@
...
@@ -20,6 +20,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include <stdarg.h>
#include "session_base.hpp"
#include "session_base.hpp"
#include "socket_base.hpp"
#include "socket_base.hpp"
#include "i_engine.hpp"
#include "i_engine.hpp"
...
...
tests/test_monitor.cpp
View file @
5ef63318
...
@@ -99,16 +99,18 @@ int main (int argc, char *argv [])
...
@@ -99,16 +99,18 @@ int main (int argc, char *argv [])
assert
(
rep
);
assert
(
rep
);
// Expects failure - invalid size
// Expects failure - invalid size
rc
=
zmq_setsockopt
(
rep
,
ZMQ_MONITOR
,
(
void
*
)
listening_sock_monitor
,
20
);
zmq_monitor_fn
*
monitor
;
monitor
=
listening_sock_monitor
;
rc
=
zmq_setsockopt
(
rep
,
ZMQ_MONITOR
,
*
(
void
**
)
&
monitor
,
20
);
assert
(
rc
==
-
1
);
assert
(
rc
==
-
1
);
assert
(
errno
==
EINVAL
);
assert
(
errno
==
EINVAL
);
rc
=
zmq_setsockopt
(
rep
,
ZMQ_MONITOR
,
(
void
*
)
listening_sock_
monitor
,
sizeof
(
void
*
));
rc
=
zmq_setsockopt
(
rep
,
ZMQ_MONITOR
,
*
(
void
**
)
&
monitor
,
sizeof
(
void
*
));
assert
(
rc
==
0
);
assert
(
rc
==
0
);
void
*
monitor
;
size_t
sz
=
sizeof
(
void
*
);
size_t
sz
=
sizeof
(
void
*
);
rc
=
zmq_getsockopt
(
rep
,
ZMQ_MONITOR
,
monitor
,
&
sz
);
rc
=
zmq_getsockopt
(
rep
,
ZMQ_MONITOR
,
&
monitor
,
&
sz
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
assert
(
monitor
==
listening_sock_monitor
);
assert
(
monitor
==
listening_sock_monitor
);
...
@@ -116,7 +118,7 @@ int main (int argc, char *argv [])
...
@@ -116,7 +118,7 @@ int main (int argc, char *argv [])
rc
=
zmq_setsockopt
(
rep
,
ZMQ_MONITOR
,
NULL
,
0
);
rc
=
zmq_setsockopt
(
rep
,
ZMQ_MONITOR
,
NULL
,
0
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
rc
=
zmq_getsockopt
(
rep
,
ZMQ_MONITOR
,
monitor
,
&
sz
);
rc
=
zmq_getsockopt
(
rep
,
ZMQ_MONITOR
,
&
monitor
,
&
sz
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
assert
(
monitor
==
listening_sock_monitor
);
assert
(
monitor
==
listening_sock_monitor
);
...
@@ -126,7 +128,8 @@ int main (int argc, char *argv [])
...
@@ -126,7 +128,8 @@ int main (int argc, char *argv [])
void
*
req
=
zmq_socket
(
ctx
,
ZMQ_REQ
);
void
*
req
=
zmq_socket
(
ctx
,
ZMQ_REQ
);
assert
(
req
);
assert
(
req
);
rc
=
zmq_setsockopt
(
req
,
ZMQ_MONITOR
,
(
void
*
)
connecting_sock_monitor
,
sizeof
(
void
*
));
monitor
=
connecting_sock_monitor
;
rc
=
zmq_setsockopt
(
req
,
ZMQ_MONITOR
,
*
(
void
**
)
&
monitor
,
sizeof
(
void
*
));
assert
(
rc
==
0
);
assert
(
rc
==
0
);
rc
=
zmq_connect
(
req
,
"tcp://127.0.0.1:5560"
);
rc
=
zmq_connect
(
req
,
"tcp://127.0.0.1:5560"
);
...
...
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