test12.cc revision 354280cf
1354280cfSShuo Chen#include "Connector.h" 2354280cfSShuo Chen#include "EventLoop.h" 3354280cfSShuo Chen 4354280cfSShuo Chen#include <stdio.h> 5354280cfSShuo Chen 6354280cfSShuo Chenmuduo::EventLoop* g_loop; 7354280cfSShuo Chen 8354280cfSShuo Chenvoid connectCallback(int sockfd) 9354280cfSShuo Chen{ 10354280cfSShuo Chen printf("connected.\n"); 11354280cfSShuo Chen g_loop->quit(); 12354280cfSShuo Chen} 13354280cfSShuo Chen 14354280cfSShuo Chenint main(int argc, char* argv[]) 15354280cfSShuo Chen{ 16354280cfSShuo Chen muduo::EventLoop loop; 17354280cfSShuo Chen g_loop = &loop; 18354280cfSShuo Chen muduo::InetAddress addr("127.0.0.1", 9981); 19354280cfSShuo Chen muduo::ConnectorPtr connector(new muduo::Connector(&loop, addr)); 20354280cfSShuo Chen connector->setNewConnectionCallback(connectCallback); 21354280cfSShuo Chen connector->start(); 22354280cfSShuo Chen 23354280cfSShuo Chen loop.loop(); 24354280cfSShuo Chen} 25