tImproved error reporting for failure of WinSock init - vaccinewars - be a doct… | |
git clone git://src.adamsgaard.dk/vaccinewars | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit ec4529cf865fafa618e04da4a5cc3214e2667cd5 | |
parent e09602092f65e25b110ec584dff468c0dc995a8a | |
Author: Ben Webb <[email protected]> | |
Date: Mon, 15 Oct 2001 15:57:46 +0000 | |
Improved error reporting for failure of WinSock init | |
Diffstat: | |
M src/error.c | 2 ++ | |
M src/network.c | 11 ++++++++++- | |
2 files changed, 12 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/src/error.c b/src/error.c | |
t@@ -100,6 +100,8 @@ ErrorType *ET_ERRNO = &ETErrno; | |
static ErrTable WSAErrStr[] = { | |
/* These are the explanations of the various Windows Sockets error codes */ | |
{ WSANOTINITIALISED,N_("WinSock has not been properly initialised") }, | |
+ { WSASYSNOTREADY,N_("Network subsystem is not ready") }, | |
+ { WSAVERNOTSUPPORTED,N_("WinSock version not supported") }, | |
{ WSAENETDOWN,N_("The network subsystem has failed") }, | |
{ WSAEADDRINUSE,N_("Address already in use") }, | |
{ WSAENETDOWN,N_("Cannot reach the network") }, | |
diff --git a/src/network.c b/src/network.c | |
t@@ -74,8 +74,17 @@ static gchar *ExpandWriteBuffer(ConnBuf *conn,int numbytes); | |
void StartNetworking() { | |
WSADATA wsaData; | |
+ LastError *error; | |
+ GString *errstr; | |
+ | |
if (WSAStartup(MAKEWORD(1,0),&wsaData)!=0) { | |
- g_warning(_("Cannot initialise WinSock!")); | |
+ error = NewError(ET_WINSOCK,WSAGetLastError(),NULL); | |
+ errstr = g_string_new(""); | |
+ g_string_assign_error(errstr,error); | |
+ g_log(NULL,G_LOG_LEVEL_CRITICAL,_("Cannot initialise WinSock (%s)!"), | |
+ errstr->str); | |
+ g_string_free(errstr,TRUE); | |
+ FreeError(error); | |
exit(1); | |
} | |
} |