Created
September 25, 2010 04:25
-
-
Save lucindo/596470 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Event.hh" | |
#include "TCPSocket.hh" | |
#include "TCPServer.hh" | |
#include <string> | |
#include <iostream> | |
class EchoSocket : public TCPSocket | |
{ | |
public: | |
void onConnect() | |
{ | |
std::cout << remoteAddr() << ':' << remotePort() << " connected" << std::endl; | |
} | |
void onClose() | |
{ | |
std::cout << remoteAddr() << ':' << remotePort() << " disconnected" << std::endl; | |
} | |
void onRead(std::string const & data) | |
{ | |
this->write(data); | |
} | |
}; | |
int main(int, char **) | |
{ | |
eventSetup(); | |
TCPServer<EchoSocket> server(std::string("127.0.0.1"), 4242); | |
// server.setup(TCPServer::ASYNC, getNumberOfCores(), TCPServer::THREAD_POOL, 2, 256); | |
server.start(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment