Added some code to help figure out errors.
This commit is contained in:
@@ -36,7 +36,14 @@ bool StepManiaLanServer::ServerStart() {
|
|||||||
statsTime = time(NULL);
|
statsTime = time(NULL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
lastError = "Failed to make socket listen.";
|
||||||
|
else
|
||||||
|
lastError = "Failed to bind socket";
|
||||||
|
else
|
||||||
|
lastError = "Failed to create socket";
|
||||||
|
|
||||||
|
lastErrorCode = server.lastCode;
|
||||||
//Hopefully we will not get here. If we did, something went wrong above.
|
//Hopefully we will not get here. If we did, something went wrong above.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ class StepManiaLanServer {
|
|||||||
StepManiaLanServer();
|
StepManiaLanServer();
|
||||||
~StepManiaLanServer();
|
~StepManiaLanServer();
|
||||||
CString servername;
|
CString servername;
|
||||||
|
CString lastError;
|
||||||
|
int lastErrorCode;
|
||||||
private:
|
private:
|
||||||
bool stop;
|
bool stop;
|
||||||
PacketFunctions Packet;
|
PacketFunctions Packet;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ void ScreenNetworkOptions::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
SCREENMAN->SystemMessage( "Server Started." );
|
SCREENMAN->SystemMessage( "Server Started." );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SCREENMAN->SystemMessage( "Server FAILED to start." );
|
SCREENMAN->SystemMessage( "Server failed: " + NSMAN->LANserver->lastError + ssprintf(" Code:%d",NSMAN->LANserver->lastErrorCode) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ bool EzSockets::create(int Protocol, int Type)
|
|||||||
{
|
{
|
||||||
state = skDISCONNECTED;
|
state = skDISCONNECTED;
|
||||||
sock = socket(AF_INET, Type, Protocol);
|
sock = socket(AF_INET, Type, Protocol);
|
||||||
|
lastCode = sock;
|
||||||
return sock > 0;
|
return sock > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,13 +94,14 @@ bool EzSockets::bind(unsigned short port)
|
|||||||
addr.sin_family = AF_INET;
|
addr.sin_family = AF_INET;
|
||||||
addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||||
addr.sin_port = htons(port);
|
addr.sin_port = htons(port);
|
||||||
|
lastCode = ::bind(sock,(struct sockaddr*)&addr, sizeof(addr));
|
||||||
return !::bind(sock,(struct sockaddr*)&addr, sizeof(addr));
|
return !lastCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EzSockets::listen()
|
bool EzSockets::listen()
|
||||||
{
|
{
|
||||||
if (::listen(sock, MAXCON))
|
lastCode = ::listen(sock, MAXCON);
|
||||||
|
if (lastCode)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
state = skLISTENING;
|
state = skLISTENING;
|
||||||
@@ -120,6 +122,8 @@ bool EzSockets::accept(EzSockets& socket)
|
|||||||
socket.sock = ::accept(sock,(struct sockaddr*) &socket.addr,
|
socket.sock = ::accept(sock,(struct sockaddr*) &socket.addr,
|
||||||
(socklen_t*) &length);
|
(socklen_t*) &length);
|
||||||
|
|
||||||
|
lastCode = socket.sock;
|
||||||
|
|
||||||
if (socket.sock <= 0)
|
if (socket.sock <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -119,6 +119,8 @@ public:
|
|||||||
|
|
||||||
SockState state;
|
SockState state;
|
||||||
|
|
||||||
|
int lastCode; //Used for debugging purposes
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//Only necessiary in windows, xbox
|
//Only necessiary in windows, xbox
|
||||||
|
|||||||
Reference in New Issue
Block a user