-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnection_test.cpp
More file actions
58 lines (44 loc) · 1.2 KB
/
connection_test.cpp
File metadata and controls
58 lines (44 loc) · 1.2 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
#include <xcppb/atom.hpp>
#include <xcppb/connection.hpp>
#include <xcppb/cookie.hpp>
#include <boost/asio/local/stream_protocol.hpp>
#include <string>
#include <iostream>
namespace asio = boost::asio;
int main()
//try
{
const std::string x_socket_path = "/tmp/.X11-unix/X0";
asio::io_service io_service;
asio::local::stream_protocol::socket s( io_service );
boost::system::error_code error;
s.connect( asio::local::stream_protocol::endpoint( x_socket_path ), error );
if( error )
{
std::cerr << error.message() << "\n";
return error.value();
}
xcppb::connection
<
asio::local::stream_protocol::socket
> c( s );
std::cerr << c;
xcppb::atom a( "NAME497" );
xcppb::atom b( "NAME498" );
xcppb::atom c_( "NAME499" );
xcppb::cookie< xcppb::atom > cookie1( c.request( a ) );
xcppb::cookie< xcppb::atom > cookie2( c.request( b ) );
xcppb::cookie< xcppb::atom > cookie3( c.request( c_ ) );
c.reply( cookie2 );
c.reply( cookie1 );
c.reply( cookie3 );
std::cout << "\n";
std::cout << "atom: " << a.id() << "\n";
std::cout << "atom: " << b.id() << "\n";
std::cout << "atom: " << c_.id() << "\n";
return 0;
}
/*catch( std::exception &e )
{
std::cerr << "Exception: " << e.what() << "\n";
}*/