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