Commit 727cd104 authored by rswindell's avatar rswindell
Browse files

Use socket_errno and socket_strerror() to include helpful error

descriptions in socket error messages in a cross-platform
(i.e. WinSock-compatible) manner.
parent 9251e439
......@@ -1532,13 +1532,13 @@ int iniGetSocketOptions(str_list_t list, const char* section, SOCKET sock
len=sizeof(type);
if((result=getsockopt(sock, SOL_SOCKET, SO_TYPE, (char*)&type, &len)) != 0) {
safe_snprintf(error,errlen,"%d getting socket type", ERROR_VALUE);
safe_snprintf(error,errlen,"%d (%s) getting socket type", ERROR_VALUE, socket_strerror(socket_errno));
return(result);
}
#ifdef IPPROTO_IPV6
len=sizeof(addr);
if((result=getsockname(sock, &addr.addr, &len)) != 0) {
safe_snprintf(error,errlen,"%d getting socket name", ERROR_VALUE);
safe_snprintf(error,errlen,"%d (%s) getting socket name", ERROR_VALUE, socket_strerror(socket_errno));
return(result);
}
#endif
......@@ -1573,8 +1573,8 @@ int iniGetSocketOptions(str_list_t list, const char* section, SOCKET sock
}
if((result=setsockopt(sock,level,option,(const char *)vp,len)) != 0) {
safe_snprintf(error,errlen,"%d setting socket option (%s, %d) to %d"
,ERROR_VALUE, name, option, value);
safe_snprintf(error,errlen,"%d (%s) setting socket option (%s, %d) to %d"
,ERROR_VALUE, socket_strerror(socket_errno), name, option, value);
return(result);
}
}
......
......@@ -152,8 +152,9 @@ BOOL DLLCALL xpms_add(struct xpms_set *xpms_set, int domain, int type,
if(type != SOCK_DGRAM) {
if(listen(xpms_set->socks[xpms_set->sock_count].sock, SOMAXCONN)==-1) {
if(xpms_set->lprintf)
xpms_set->lprintf(LOG_WARNING, "%04d !%s ERROR %d listen()ing on port %d"
,xpms_set->socks[xpms_set->sock_count].sock, prot, ERROR_VALUE, port);
xpms_set->lprintf(LOG_WARNING, "%04d !%s ERROR %d (%s) listening on port %d"
,xpms_set->socks[xpms_set->sock_count].sock, prot, ERROR_VALUE
,socket_strerror(socket_errno), port);
closesocket(xpms_set->socks[xpms_set->sock_count].sock);
FREE_AND_NULL(xpms_set->socks[xpms_set->sock_count].address);
FREE_AND_NULL(xpms_set->socks[xpms_set->sock_count].prot);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment