11
2-
3- // C++
4- #include < stdio.h>
5-
62#include < future>
3+ #include < iostream>
74#include < memory>
85#include < string>
96
@@ -25,7 +22,7 @@ int main()
2522 longStr += " 1234567890" ;
2623
2724 auto clientSocket = syncCreateSocket (context, IOSocketType::Connector, " ClientSocket" );
28- printf ( " Successfully created socket.\n " ) ;
25+ std::cout << " Successfully created socket.\n " ;
2926
3027 constexpr size_t msgCnt = 100'000 ;
3128
@@ -34,9 +31,8 @@ int main()
3431 std::vector<std::promise<std::pair<Message, Error>>> recvPromises;
3532 recvPromises.reserve (msgCnt + 10 );
3633
37- // syncConnectSocket(clientSocket, "tcp://51.15.214.200:32912");
3834 syncConnectSocket (clientSocket, " tcp://127.0.0.1:8080" );
39- printf ( " Connected to server.\n " ) ;
35+ std::cout << " Connected to server.\n " ;
4036
4137 const std::string_view line = longStr;
4238
@@ -64,19 +60,19 @@ int main()
6460 auto future = x.get_future ();
6561 future.wait ();
6662 }
67- printf ( " send completes\n " ) ;
63+ std::cout << " Send completes. \n " ;
6864
6965 for (auto && x: recvPromises) {
7066 auto future = x.get_future ();
7167 Message msg = future.get ().first ;
7268 if (msg.payload .as_string () != longStr) {
73- printf ( " Checksum failed, %s \n " , msg.payload .as_string ()-> c_str ()) ;
69+ std::cerr << " Checksum failed, " << * msg.payload .as_string () << std::endl ;
7470 exit (1 );
7571 }
7672 }
77- printf ( " recv completes\n " ) ;
73+ std::cout << " Recv completes. \n " ;
7874
79- printf ( " Send and recv %lu messages, checksum fits, exiting.\n " , msgCnt) ;
75+ std::cout << " Send and recv " << msgCnt << " messages, checksum fits, exiting.\n " ;
8076
8177 context.removeIOSocket (clientSocket);
8278
0 commit comments