-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Runs an identical test case to the existing UDP client code, and utilizes the tcp_server python tool to echo a Person Protobuf message back and forth.
- Loading branch information
1 parent
a4c65ff
commit 7cd6f2d
Showing
2 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,8 @@ int main(int argc, char* argv[]) | |
{ | ||
asio::io_context context; | ||
|
||
udp::resolver resolver(context); | ||
// UDP Test | ||
/*udp::resolver resolver(context); | ||
auto endpoints = resolver.resolve(udp::v4(), "127.0.0.1", "10000"); | ||
UdpClient<Person> client(context, endpoints); | ||
|
@@ -33,8 +34,28 @@ int main(int argc, char* argv[]) | |
client.write(message); | ||
LOG(INFO) << client.getReadMessage().body(); | ||
std::this_thread::sleep_for(std::chrono::duration(std::chrono::milliseconds(1000))); | ||
} | ||
}*/ | ||
|
||
// TCP Test | ||
tcp::resolver resolver(context); | ||
auto endpoints = resolver.resolve(tcp::v4(), "127.0.0.1", "10000"); | ||
TcpClient<Person> client(context, endpoints); | ||
|
||
std::thread t1([&context]() { context.run(); }); | ||
while (true) | ||
{ | ||
static int count = 0; | ||
Person person; | ||
person.set_name("Daniel Burke"); | ||
person.set_email("[email protected]"); | ||
auto phone = person.add_phones(); | ||
|
||
Message<Person> message(person); | ||
client.write(message); | ||
LOG(INFO) << client.getReadMessage().body(); | ||
std::this_thread::sleep_for(std::chrono::duration(std::chrono::milliseconds(1000))); | ||
} | ||
|
||
client.close(); | ||
t1.join(); | ||
|
||
|