15 #include <Atlas/Net/Stream.h> 17 #include "DebugBridge.h" 24 #include <sys/types.h> 25 #include <sys/socket.h> 26 #include <netinet/in.h> 33 using namespace Atlas;
39 cout <<
"Sending hello world message... " << flush;
40 c.streamMessage(Bridge::mapBegin);
41 c.mapStringItem(
"hello",
"world");
43 cout <<
"done." << endl;
46 int main(
int argc,
char** argv)
48 int cli_fd = socket(PF_INET, SOCK_STREAM, 0);
50 cerr <<
"ERROR: Could not open socket" << endl << flush;
54 cout <<
"Connecting..." << flush;
56 struct sockaddr_in sin;
57 sin.sin_family = AF_INET;
58 sin.sin_port = htons(6767);
59 sin.sin_addr.s_addr = htonl(0x7f000001);
62 int res = connect(cli_fd, (
struct sockaddr *)&sin,
sizeof(sin));
65 iostream connection(&cli_buf);
68 cerr <<
"ERROR: Connection failed" << endl << flush;
77 cout <<
"Negotiating... " << flush;
82 cout <<
"done" << endl;
86 cerr <<
"Failed to negotiate" << endl;
101 cout <<
"Sleeping for 2 seconds... " << flush;
104 cout <<
"done." << endl;
107 if (!connection) cout <<
"Server exited." << endl;
else {
109 cout <<
"Closing connection... " << flush;
115 cout <<
"done." << endl;