summaryrefslogtreecommitdiff
path: root/client/client_windows.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'client/client_windows.cpp')
-rw-r--r--client/client_windows.cpp46
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;
+}