Skip to content

Commit

Permalink
test edge case dissconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Gray committed Aug 12, 2014
1 parent ff1ca24 commit 811c802
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/tests/test_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,42 @@ BOOST_AUTO_TEST_CASE( simple_pull_push )
BOOST_CHECK(!puller.has_more_parts());
}

BOOST_AUTO_TEST_CASE( seperate_pull_push_disconnect )
{
zmqpp::context pull_context;
zmqpp::socket puller(pull_context, zmqpp::socket_type::pull);
puller.set(zmqpp::socket_option::receive_high_water_mark, 5);
puller.bind("tcp://*:65400");

zmqpp::context push_context;
zmqpp::socket pusher(push_context, zmqpp::socket_type::push);
pusher.set( zmqpp::socket_option::immediate, true );
pusher.set(zmqpp::socket_option::send_high_water_mark, 5);
pusher.connect("tcp://localhost:65400");

{
BOOST_CHECK(pusher.send("hello world!"));
wait_for_socket(puller);
std::string message;
BOOST_CHECK(puller.receive(message));

zmqpp::context temp_context;
zmqpp::socket temp_socket( temp_context, zmqpp::socket_type::pull );
puller.set(zmqpp::socket_option::receive_high_water_mark, 5);

std::swap(temp_context, pull_context);
std::swap(temp_socket, puller);
}

sleep(5);
pusher.disconnect("tcp://localhost:65400");
sleep(5);
puller.bind("tcp://*:65400");
sleep(5);

BOOST_CHECK(pusher.send("hello world!"));
}

BOOST_AUTO_TEST_CASE( multipart_pair )
{
zmqpp::context context;
Expand Down

0 comments on commit 811c802

Please sign in to comment.