ceremonyclient/emp-tool/test/netio2.cpp
Cassandra Heart dbd95bd9e9
v2.1.0 (#439)
* v2.1.0 [omit consensus and adjacent] - this commit will be amended with the full release after the file copy is complete

* 2.1.0 main node rollup
2025-09-30 02:48:15 -05:00

37 lines
906 B
C++

#include "emp-tool/emp-tool.h"
#include <iostream>
using namespace std;
using namespace emp;
int main(int argc, char** argv) {
int port;
int64_t party;
parse_party_and_port(argv, &party, &port);
NetIO * io = new NetIO(party == ALICE ? nullptr:"127.0.0.1", port);
int length = NETWORK_BUFFER_SIZE2/5+100;
char * data = new char[length];
char * data2 = new char[length];
PRG prg(&zero_block);
for(int i = 0; i < 1000; ++i)
if(party == ALICE) {
prg.random_data(data, length);
io->send_data(data, length);
io->send_data(data, length);
// io->flush();
io->recv_data(data2, length);
assert(memcmp(data, data2, length) == 0);
} else {//party == BOB
prg.random_data(data2, length);
io->recv_data(data, length);
io->recv_data(data, length);
// io->flush();
io->send_data(data2, length);
assert(memcmp(data, data2, length) == 0);
}
io->flush();
cout <<"done\n";
delete io;
}