Skip to content

Instantly share code, notes, and snippets.

@NightBrownie
Created December 24, 2011 11:44
Show Gist options
  • Save NightBrownie/1517182 to your computer and use it in GitHub Desktop.
Save NightBrownie/1517182 to your computer and use it in GitHub Desktop.
#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