diff options
| author | JustSomePwner <crotchyalt@gmail.com> | 2018-08-30 14:01:54 +0200 |
|---|---|---|
| committer | JustSomePwner <crotchyalt@gmail.com> | 2018-08-30 14:01:54 +0200 |
| commit | 7ccb819f867493f8ec202ea3b39c94c198c64584 (patch) | |
| tree | 94622e61af0ff359e3d6689cf274d74f60b2492a /client/client_windows.cpp | |
| parent | 564d979b79e8a5aaa5014eba0ecd36c61575934f (diff) | |
first
Diffstat (limited to 'client/client_windows.cpp')
| -rw-r--r-- | client/client_windows.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
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 <Windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <iostream>
+
+#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;
+}
|
