From 7ccb819f867493f8ec202ea3b39c94c198c64584 Mon Sep 17 00:00:00 2001 From: JustSomePwner Date: Thu, 30 Aug 2018 14:01:54 +0200 Subject: first --- client/client_windows.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 client/client_windows.cpp (limited to 'client/client_windows.cpp') diff --git a/client/client_windows.cpp b/client/client_windows.cpp new file mode 100644 index 0000000..76bd776 --- /dev/null +++ b/client/client_windows.cpp @@ -0,0 +1,46 @@ +#include +#include +#include +#include +#include + +#pragma comment( lib, "ws2_32.lib" ) + +#include "connect.hpp" + +int main( ) { + std::string ip; + std::cin >> ip; + + client::c_connect c( ip.c_str( ) ); + if( !c.setup( ) ) + return 1; + + if( !c.connect( ) ) + return 2; + + + const char* yes = "hello server"; + char buf[ 255 ]; + memcpy( buf, yes, strlen( yes ) ); + + c.send_msg( ( uint8_t* )( buf ), strlen( yes ) ); + printf( "message sent\n" ); + + auto msg = c.get_msg( ); + while( !msg.size( ) ) { + Sleep( 1 ); + } + + printf( "[message received]: " ); + for( auto& it : msg ) + printf( "%c", it ); + + printf( "\n" ); + + c.send_msg( ( uint8_t* )( buf ), strlen( yes ) ); + + c.~c_connect( ); + system( "pause" ); + return 0; +} -- cgit v1.2.3