diff options
Diffstat (limited to 'src/madc.cpp')
-rw-r--r-- | src/madc.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/madc.cpp b/src/madc.cpp index 08fb3b3..790baf5 100644 --- a/src/madc.cpp +++ b/src/madc.cpp @@ -24,34 +24,34 @@ int main() { Mad::Net::Connection::init(); - + Mad::Net::ClientConnection connection; - + try { connection.connect(Mad::Net::IPAddress("127.0.0.1", 6666)); - + while(connection.isConnecting()) { struct pollfd fd = connection.getPollfd(); - + if(poll(&fd, 1, 10000) > 0) connection.sendReceive(fd.revents); } - + connection.send(Mad::Net::Packet(Mad::Net::Packet::TYPE_DEBUG, 0x1234)); connection.send(Mad::Net::Packet(Mad::Net::Packet::TYPE_DISCONNECT_REQ, 0xABCD)); - + while(!connection.sendQueueEmpty()) { struct pollfd fd = connection.getPollfd(); - + if(poll(&fd, 1, 10000) > 0) connection.sendReceive(fd.revents); } - + connection.disconnect(); - + while(connection.isConnected()) { struct pollfd fd = connection.getPollfd(); - + if(poll(&fd, 1, 10000) > 0) connection.sendReceive(fd.revents); } @@ -59,10 +59,8 @@ int main() { catch(Mad::Net::Exception &e) { std::cerr << "Connection error: " << e.what() << std::endl; } - - connection.disconnect(); - + Mad::Net::Connection::deinit(); - + return 0; } |