summaryrefslogtreecommitdiffstats
path: root/src/mad.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mad.cpp')
-rw-r--r--src/mad.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/mad.cpp b/src/mad.cpp
index f6604a5..dc3241e 100644
--- a/src/mad.cpp
+++ b/src/mad.cpp
@@ -17,6 +17,47 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "Net/ClientConnection.h"
+#include "Net/IPAddress.h"
+#include "Common/RequestManager.h"
+
+#include <iostream>
+
+
int main() {
+ Mad::Net::Connection::init();
+
+ Mad::Common::RequestManager requestManager(false);
+ Mad::Net::ClientConnection *connection = new Mad::Net::ClientConnection;
+
+ try {
+ connection->connect(Mad::Net::IPAddress("127.0.0.1"), true);
+
+ while(connection->isConnecting()) {
+ struct pollfd fd = connection->getPollfd();
+
+ if(poll(&fd, 1, 10000) > 0)
+ connection->sendReceive(fd.revents);
+ }
+
+ requestManager.registerConnection(connection);
+
+ while(connection->isConnected()) {
+ struct pollfd fd = connection->getPollfd();
+
+ if(poll(&fd, 1, 10000) > 0)
+ connection->sendReceive(fd.revents);
+ }
+
+ requestManager.unregisterConnection(connection);
+ }
+ catch(Mad::Net::Exception &e) {
+ std::cerr << "Connection error: " << e.what() << std::endl;
+ }
+
+ delete connection;
+
+ Mad::Net::Connection::deinit();
+
return 0;
}