Created
December 24, 2011 11:44
-
-
Save NightBrownie/1517182 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 "stdafx.h" | |
#include "Server.h" | |
#include <conio.h> | |
#include <iostream> | |
using namespace std; | |
Server* s; | |
class Listener : public ServerListener { | |
public: | |
void OnNewClient(int id) { | |
cout << "New client " << id << "\n"; | |
s->sendData(id, "Hello\n"); | |
} | |
void OnNewData(int id, char* data) { | |
cout << "<< [" << id << "] " << data << "\n"; | |
} | |
}; | |
void _tmain(void) | |
{ | |
Listener* l = new Listener(); | |
pthread_t* thread1 = new pthread_t(); | |
s = new Server(1234, l, "One server"); | |
cout << "Hello from server" << s->name << endl; | |
pthread_create(thread1, NULL, Server::serve, s); | |
while(1); | |
return ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment