CServerLoop -> CServer

Will have to extract the select() loop logic form it afterwards.
This commit is contained in:
q3k 2012-11-27 11:06:04 +01:00
parent c875619930
commit c8aac8900e
5 changed files with 15 additions and 14 deletions

View file

@ -1,9 +1,10 @@
#include "ServerLoop.h"
#include "ClientConnection.h"
using namespace umcs;
#include "config.h"
#include <cstring>
#include "Server.h"
#include "packets/C2S02Handshake.h"
#include "packets/C2SFEServerListPing.h"
#include "packets/GenericS2CPacket.h"

View file

@ -1,6 +1,6 @@
CXXFLAGS="-std=c++0x"
OBJECTS := ServerLoop.o ClientConnection.o Client.o main.o \
OBJECTS := Server.o ClientConnection.o Client.o main.o \
packets/GenericC2SPacket.o packets/C2S02Handshake.o packets/C2SFEServerListPing.o \
packets/GenericS2CPacket.o

View file

@ -1,9 +1,9 @@
#include "ServerLoop.h"
#include "Server.h"
using namespace umcs;
#include "config.h"
CServerLoop::CServerLoop(short Port = 25565)
CServer::CServer(short Port = 25565)
{
m_GamePort = Port;
m_GameSocket = socket(AF_INET, SOCK_STREAM, 0);
@ -14,7 +14,7 @@ CServerLoop::CServerLoop(short Port = 25565)
}
}
TSocket CServerLoop::Select(unsigned int TimeoutMicro)
TSocket CServer::Select(unsigned int TimeoutMicro)
{
FD_ZERO(&m_RSockets);
FD_SET(m_GameSocket, &m_RSockets);
@ -27,7 +27,7 @@ TSocket CServerLoop::Select(unsigned int TimeoutMicro)
return select(FD_SETSIZE, &m_RSockets, (fd_set *)0, (fd_set *)0, &Timeout);
}
int CServerLoop::MakeSocketNonBlocking(TSocket Socket)
int CServer::MakeSocketNonBlocking(TSocket Socket)
{
int Options = fcntl(Socket, F_GETFL);
if (Options < 0)
@ -43,7 +43,7 @@ int CServerLoop::MakeSocketNonBlocking(TSocket Socket)
}
}
int CServerLoop::Run(void)
int CServer::Run(void)
{
if (m_GameSocket == -1)
return -1;

View file

@ -1,5 +1,5 @@
#ifndef __SERVER_LOOP_H__
#define __SERVER_LOOP_H__
#ifndef __SERVER_H__
#define __SERVER_H__
#include "config.h"
#include "ClientConnection.h"
@ -16,7 +16,7 @@ extern "C"
namespace umcs {
// basic server class that uses BSD sockets
class CServerLoop {
class CServer {
private:
fd_set m_RSockets;
TSocket Select(unsigned int TimeoutMicro);
@ -27,7 +27,7 @@ namespace umcs {
short m_GamePort;
public:
// default constructor that binds to all interfaces
CServerLoop(short Port);
CServer(short Port);
// start the server
int Run(void);

View file

@ -1,8 +1,8 @@
#include "ServerLoop.h"
#include "Server.h"
int main(int argc, char **argv)
{
umcs::CServerLoop Loop(25565);
Loop.Run();
umcs::CServer Server(25565);
Server.Run();
return 0;
}