aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <0xdec05eba@gmail.com>2018-10-19 14:19:12 +0200
committerdec05eba <0xdec05eba@gmail.com>2018-10-19 14:19:15 +0200
commit3565289c19974ca874f87429cc74a87558249c8e (patch)
treef3afeb061700e5e168dbee02e7694e3bc97be977 /tests
parenta4e128e5e46c9fcf00fd874c8386988f9d3b73fa (diff)
Use sendmsg and recvmsg instead of send and recv to receive one message at a time
Diffstat (limited to 'tests')
-rw-r--r--tests/main.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/main.cpp b/tests/main.cpp
index d650128..2d1d505 100644
--- a/tests/main.cpp
+++ b/tests/main.cpp
@@ -15,29 +15,38 @@ int main()
sibs::BootstrapConnection connection1(sibs::Ipv4("127.0.0.1", PORT));
bool gotData1 = false;
- connection1.listen(key, [&gotData1](const sibs::DirectConnectionPeer *peer, const void *data, const sibs::usize size)
+ bool gotAsdf1 = false;
+ connection1.listen(key, [&gotData1, &gotAsdf1](const sibs::DirectConnectionPeer *peer, const void *data, const sibs::usize size)
{
if(size == 5 && strncmp((const char*)data, "hello", 5) == 0)
gotData1 = true;
+ if(size == 4 && strncmp((const char*)data, "asdf", 4) == 0)
+ gotAsdf1 = true;
return true;
});
sibs::BootstrapConnection connection2(sibs::Ipv4("127.0.0.1", PORT));
bool gotData2 = false;
- connection2.listen(key, [&gotData2](const sibs::DirectConnectionPeer *peer, const void *data, const sibs::usize size)
+ bool gotAsdf2 = false;
+ connection2.listen(key, [&gotData2, &gotAsdf2](const sibs::DirectConnectionPeer *peer, const void *data, const sibs::usize size)
{
if(size == 5 && strncmp((const char*)data, "hello", 5) == 0)
gotData2 = true;
+ if(size == 4 && strncmp((const char*)data, "asdf", 4) == 0)
+ gotAsdf2 = true;
return true;
});
// wait until connection1 and connection2 receive each other as peers from bootstrap node
std::this_thread::sleep_for(std::chrono::seconds(3));
connection1.put(key, "hello", 5);
+ connection1.put(key, "asdf", 4);
std::this_thread::sleep_for(std::chrono::seconds(3));
REQUIRE(gotData1);
+ REQUIRE(gotAsdf1);
REQUIRE(gotData2);
+ REQUIRE(gotAsdf2);
return 0;
}