Mercurial > hg > nnchat
diff libnnchat.c @ 90:1e0bf7b4fd41
Move socket error handling functions to libnnchat.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 06 May 2009 23:55:21 +0300 |
parents | c2d916b340bf |
children | acfc4b4bc180 |
line wrap: on
line diff
--- a/libnnchat.c Wed May 06 05:05:02 2009 +0300 +++ b/libnnchat.c Wed May 06 23:55:21 2009 +0300 @@ -20,6 +20,38 @@ const int numHTMLEntities = (sizeof(HTMLEntities) / sizeof(HTMLEntities[0])); +#ifdef __WIN32 +const char *hstrerror(int err) +{ + static char buf[64]; + snprintf(buf, sizeof(buf), "Error #%d", err); + return buf; +} + +int getSocketErrno(void) +{ + return WSAGetLastError(); +} + +const char *getSocketErrStr(int err) +{ + static char buf[64]; + snprintf(buf, sizeof(buf), "Error #%d", err); + return buf; +} +#else +int getSocketErrno(void) +{ + return errno; +} + +const char *getSocketErrStr(int err) +{ + return strerror(err); +} +#endif + + int openConnection(struct in_addr *addr, const int port) { struct sockaddr_in tmpAddr;