1#include "Connector.h" 2#include "EventLoop.h" 3 4#include <stdio.h> 5 6muduo::EventLoop* g_loop; 7 8void connectCallback(int sockfd) 9{ 10 printf("connected.\n"); 11 g_loop->quit(); 12} 13 14int main(int argc, char* argv[]) 15{ 16 muduo::EventLoop loop; 17 g_loop = &loop; 18 muduo::InetAddress addr("127.0.0.1", 9981); 19 muduo::ConnectorPtr connector(new muduo::Connector(&loop, addr)); 20 connector->setNewConnectionCallback(connectCallback); 21 connector->start(); 22 23 loop.loop(); 24} 25