blob: 76bd776318249950052edc4e758d96a298222091 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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;
}
|