mirror of
https://github.com/glest/glest-source.git
synced 2025-09-28 16:39:01 +02:00
Ported auto-discover LAN connect to win32
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
#include <string>
|
||||
#include <winsock.h>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "thread.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
@@ -54,14 +56,16 @@ private:
|
||||
protected:
|
||||
static SocketManager socketManager;
|
||||
SOCKET sock;
|
||||
static int broadcast_portno;
|
||||
|
||||
public:
|
||||
Socket(SOCKET sock);
|
||||
Socket();
|
||||
~Socket();
|
||||
virtual ~Socket();
|
||||
|
||||
static bool enableDebugText;
|
||||
static bool enableNetworkDebugInfo;
|
||||
static int getBroadCastPort() { return broadcast_portno; }
|
||||
static void setBroadCastPort(int value) { broadcast_portno = value; }
|
||||
static std::vector<std::string> getLocalIPAddressList();
|
||||
|
||||
// Int lookup is socket fd while bool result is whether or not that socket was signalled for reading
|
||||
static bool hasDataToRead(std::map<int,bool> &socketTriggeredList);
|
||||
@@ -96,6 +100,27 @@ protected:
|
||||
class ClientSocket: public Socket{
|
||||
public:
|
||||
void connect(const Ip &ip, int port);
|
||||
static std::vector<string> discoverServers();
|
||||
};
|
||||
|
||||
class BroadCastSocketThread : public Thread
|
||||
{
|
||||
private:
|
||||
Mutex mutexRunning;
|
||||
Mutex mutexQuit;
|
||||
|
||||
bool quit;
|
||||
bool running;
|
||||
|
||||
void setRunningStatus(bool value);
|
||||
void setQuitStatus(bool value);
|
||||
|
||||
public:
|
||||
BroadCastSocketThread();
|
||||
virtual void execute();
|
||||
void signalQuit();
|
||||
bool getQuitStatus();
|
||||
bool getRunningStatus();
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
@@ -105,13 +130,19 @@ public:
|
||||
class ServerSocket: public Socket{
|
||||
|
||||
public:
|
||||
ServerSocket();
|
||||
virtual ~ServerSocket();
|
||||
|
||||
void bind(int port);
|
||||
void listen(int connectionQueueSize= SOMAXCONN);
|
||||
Socket *accept();
|
||||
void stopBroadCastThread();
|
||||
|
||||
protected:
|
||||
|
||||
void broadcast_thread();
|
||||
BroadCastSocketThread *broadCastThread;
|
||||
void startBroadCastThread();
|
||||
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
Reference in New Issue
Block a user