Added some code to help figure out errors.

This commit is contained in:
Charles Lohr
2004-09-06 18:20:16 +00:00
parent d01e654507
commit bc628082ba
5 changed files with 19 additions and 4 deletions
+7
View File
@@ -36,7 +36,14 @@ bool StepManiaLanServer::ServerStart() {
statsTime = time(NULL);
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.
return false;
}
+2
View File
@@ -81,6 +81,8 @@ class StepManiaLanServer {
StepManiaLanServer();
~StepManiaLanServer();
CString servername;
CString lastError;
int lastErrorCode;
private:
bool stop;
PacketFunctions Packet;
+1 -1
View File
@@ -91,7 +91,7 @@ void ScreenNetworkOptions::HandleScreenMessage( const ScreenMessage SM )
SCREENMAN->SystemMessage( "Server Started." );
}
else
SCREENMAN->SystemMessage( "Server FAILED to start." );
SCREENMAN->SystemMessage( "Server failed: " + NSMAN->LANserver->lastError + ssprintf(" Code:%d",NSMAN->LANserver->lastErrorCode) );
}
}
+7 -3
View File
@@ -81,6 +81,7 @@ bool EzSockets::create(int Protocol, int Type)
{
state = skDISCONNECTED;
sock = socket(AF_INET, Type, Protocol);
lastCode = sock;
return sock > 0;
}
@@ -93,13 +94,14 @@ bool EzSockets::bind(unsigned short port)
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_ANY);
addr.sin_port = htons(port);
return !::bind(sock,(struct sockaddr*)&addr, sizeof(addr));
lastCode = ::bind(sock,(struct sockaddr*)&addr, sizeof(addr));
return !lastCode;
}
bool EzSockets::listen()
{
if (::listen(sock, MAXCON))
lastCode = ::listen(sock, MAXCON);
if (lastCode)
return false;
state = skLISTENING;
@@ -120,6 +122,8 @@ bool EzSockets::accept(EzSockets& socket)
socket.sock = ::accept(sock,(struct sockaddr*) &socket.addr,
(socklen_t*) &length);
lastCode = socket.sock;
if (socket.sock <= 0)
return false;
+2
View File
@@ -119,6 +119,8 @@ public:
SockState state;
int lastCode; //Used for debugging purposes
private:
//Only necessiary in windows, xbox