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
aaeae8de
Commit
aaeae8de
authored
Jan 20, 2014
by
Pieter Hintjens
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #841 from Prarrot/master
ZMQ_CONNECT_RID tests and man
parents
2f854472
3fbc10eb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
7 deletions
+37
-7
CMakeLists.txt
CMakeLists.txt
+1
-0
zmq_setsockopt.txt
doc/zmq_setsockopt.txt
+26
-0
router.cpp
src/router.cpp
+5
-5
stream.cpp
src/stream.cpp
+5
-2
No files found.
CMakeLists.txt
View file @
aaeae8de
...
...
@@ -622,6 +622,7 @@ set(tests
test_timeo
test_many_sockets
test_diffserv
test_connect_rid
)
if
(
NOT WIN32
)
list
(
APPEND tests
...
...
doc/zmq_setsockopt.txt
View file @
aaeae8de
...
...
@@ -67,6 +67,32 @@ Default value:: 100
Applicable socket types:: all, only for connection-oriented transports.
ZMQ_CONNECT_RID: Assign the next outbound connection id
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_CONNECT_RID' option sets the peer id of the next host connected
via the zmq_connect() call, and immediately readies that connection for
data transfer with the named id. This option applies only to the first
subsequent call to zmq_connect(), calls thereafter use default connection
behavior.
Typical use is to set this socket option on each zmq_connect() attempt
to a new host. Each connection should be assigned a unique name. Duplicated
names will trigger default connection behavior.
Useful when connecting ROUTER to ROUTER, or STREAM to STREAM, as it
allows for immediate sending to peers. Outbound id framing requirements
for ROUTER and STREAM sockets apply.
The peer id should be from 1 to 255 bytes long and MAY NOT start with
binary zero.
[horizontal]
Option value type:: binary data
Option value unit:: N/A
Default value:: NULL
Applicable socket types:: ZMQ_ROUTER, ZMQ_STREAM
ZMQ_CONFLATE: Keep only last message
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If set, a socket shall keep only one message in its inbound/outbound
...
...
src/router.cpp
View file @
aaeae8de
...
...
@@ -387,13 +387,15 @@ bool zmq::router_t::identify_peer (pipe_t *pipe_)
msg_t
msg
;
blob_t
identity
;
bool
ok
;
bool
connect_rid_used
=
false
;
if
(
connect_rid
.
length
())
{
identity
=
blob_t
((
unsigned
char
*
)
connect_rid
.
c_str
(),
connect_rid
.
length
());
connect_rid
.
clear
();
connect_rid_used
=
true
;
outpipes_t
::
iterator
it
=
outpipes
.
find
(
identity
);
if
(
it
!=
outpipes
.
end
())
{
return
false
;
// duplicate connection
}
}
else
if
(
options
.
raw_sock
)
{
// Always assign identity for raw-socket
...
...
@@ -402,6 +404,7 @@ bool zmq::router_t::identify_peer (pipe_t *pipe_)
put_uint32
(
buf
+
1
,
next_rid
++
);
identity
=
blob_t
(
buf
,
sizeof
buf
);
}
else
if
(
!
options
.
raw_sock
)
{
// Pick up handshake cases and also case where next identity is set
msg
.
init
();
...
...
@@ -409,9 +412,6 @@ bool zmq::router_t::identify_peer (pipe_t *pipe_)
if
(
!
ok
)
return
false
;
if
(
connect_rid_used
)
// we read but do not use identity from peer
msg
.
close
();
else
if
(
msg
.
size
()
==
0
)
{
// Fall back on the auto-generation
unsigned
char
buf
[
5
];
...
...
src/stream.cpp
View file @
aaeae8de
...
...
@@ -266,10 +266,13 @@ void zmq::stream_t::identify_peer (pipe_t *pipe_)
identity
=
blob_t
((
unsigned
char
*
)
connect_rid
.
c_str
(),
connect_rid
.
length
());
connect_rid
.
clear
();
outpipes_t
::
iterator
it
=
outpipes
.
find
(
identity
);
if
(
it
!=
outpipes
.
end
())
goto
d
;
}
else
{
put_uint32
(
buffer
+
1
,
next_rid
++
);
blob_t
identity
=
blob_t
(
buffer
,
sizeof
buffer
);
d
:
put_uint32
(
buffer
+
1
,
next_rid
++
);
identity
=
blob_t
(
buffer
,
sizeof
buffer
);
memcpy
(
options
.
identity
,
identity
.
data
(),
identity
.
size
());
options
.
identity_size
=
identity
.
size
();
}
...
...
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