summaryrefslogtreecommitdiffhomepage
path: root/examples/simple_unique_socket/example.cc
blob: b5bd34f212b5e4632e33741bfac8f33ece33384a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <ocl/unique_socket.hpp>
#include <ocl/print.hpp>

/// @brief Basic Send test
int main()
{
	ocl::unique_socket sock = ocl::unique_socket::make_socket<8005>(ocl::unique_socket::any_address, true);

	char buf_dst[512] = {"HELLO, WORLD\0"};

	ocl::unique_socket sock2 = ocl::unique_socket::make_socket<8005>(ocl::unique_socket::any_address, false);

	char buf_dst2[512] = {0};

	auto new_sock = sock.accept();
	new_sock.write_from_buffer(buf_dst, strlen(buf_dst));
	sock2.read_client_buffer(buf_dst2, strlen(buf_dst));
	std::cout << "result:" << buf_dst2 << "\n";


	return EXIT_SUCCESS;
}