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
bf74c0cf
Commit
bf74c0cf
authored
Jul 09, 2014
by
Martin Hurton
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1124 from ricnewton/master
Add test for unbinding inproc socket.
parents
e71ebbb7
31cff7cc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
test_inproc_connect.cpp
tests/test_inproc_connect.cpp
+51
-0
No files found.
tests/test_inproc_connect.cpp
View file @
bf74c0cf
...
...
@@ -411,6 +411,56 @@ void test_connect_only ()
assert
(
rc
==
0
);
}
void
test_unbind
()
{
void
*
ctx
=
zmq_ctx_new
();
assert
(
ctx
);
// Bind and unbind socket 1
void
*
bindSocket1
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
assert
(
bindSocket1
);
int
rc
=
zmq_bind
(
bindSocket1
,
"inproc://unbind"
);
assert
(
rc
==
0
);
zmq_unbind
(
bindSocket1
,
"inproc://unbind"
);
assert
(
rc
==
0
);
// Bind socket 2
void
*
bindSocket2
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
assert
(
bindSocket2
);
rc
=
zmq_bind
(
bindSocket2
,
"inproc://unbind"
);
assert
(
rc
==
0
);
// Now connect
void
*
connectSocket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
assert
(
connectSocket
);
rc
=
zmq_connect
(
connectSocket
,
"inproc://unbind"
);
assert
(
rc
==
0
);
// Queue up some data
rc
=
zmq_send_const
(
connectSocket
,
"foobar"
,
6
,
0
);
assert
(
rc
==
6
);
// Read pending message
zmq_msg_t
msg
;
rc
=
zmq_msg_init
(
&
msg
);
assert
(
rc
==
0
);
rc
=
zmq_msg_recv
(
&
msg
,
bindSocket2
,
0
);
assert
(
rc
==
6
);
void
*
data
=
zmq_msg_data
(
&
msg
);
assert
(
memcmp
(
"foobar"
,
data
,
6
)
==
0
);
// Cleanup
rc
=
zmq_close
(
connectSocket
);
assert
(
rc
==
0
);
rc
=
zmq_close
(
bindSocket1
);
assert
(
rc
==
0
);
rc
=
zmq_close
(
bindSocket2
);
assert
(
rc
==
0
);
rc
=
zmq_ctx_term
(
ctx
);
assert
(
rc
==
0
);
}
int
main
(
void
)
{
setup_test_environment
();
...
...
@@ -423,6 +473,7 @@ int main (void)
test_simultaneous_connect_bind_threads
();
test_identity
();
test_connect_only
();
test_unbind
();
return
0
;
}
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