test12.cc revision 04e5c324
104e5c324SShuo Chen#include "Connector.h" 204e5c324SShuo Chen#include "EventLoop.h" 304e5c324SShuo Chen 404e5c324SShuo Chen#include <stdio.h> 504e5c324SShuo Chen 604e5c324SShuo Chenmuduo::EventLoop* g_loop; 704e5c324SShuo Chen 804e5c324SShuo Chenvoid connectCallback(int sockfd) 904e5c324SShuo Chen{ 1004e5c324SShuo Chen printf("connected.\n"); 1104e5c324SShuo Chen g_loop->quit(); 1204e5c324SShuo Chen} 1304e5c324SShuo Chen 1404e5c324SShuo Chenint main(int argc, char* argv[]) 1504e5c324SShuo Chen{ 1604e5c324SShuo Chen muduo::EventLoop loop; 1704e5c324SShuo Chen g_loop = &loop; 1804e5c324SShuo Chen muduo::InetAddress addr("127.0.0.1", 9981); 1904e5c324SShuo Chen muduo::ConnectorPtr connector(new muduo::Connector(&loop, addr)); 2004e5c324SShuo Chen connector->setNewConnectionCallback(connectCallback); 2104e5c324SShuo Chen connector->start(); 2204e5c324SShuo Chen 2304e5c324SShuo Chen loop.loop(); 2404e5c324SShuo Chen} 25