-const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.24 2002/03/07 03:51:36 oes Exp $";
+const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.26 2002/03/11 22:07:02 david__schmidt Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
*
* Revisions :
* $Log: jbsockets.c,v $
+ * Revision 1.26 2002/03/11 22:07:02 david__schmidt
+ * OS/2 port maintenance:
+ * - Fixed EMX build - it had decayed a little
+ * - Fixed inexplicable crash during FD_ZERO - must be due to a bad macro.
+ * substituted a memset for now.
+ *
+ * Revision 1.25 2002/03/09 20:03:52 jongfoster
+ * - Making various functions return int rather than size_t.
+ * (Undoing a recent change). Since size_t is unsigned on
+ * Windows, functions like read_socket that return -1 on
+ * error cannot return a size_t.
+ *
+ * THIS WAS A MAJOR BUG - it caused frequent, unpredictable
+ * crashes, and also frequently caused JB to jump to 100%
+ * CPU and stay there. (Because it thought it had just
+ * read ((unsigned)-1) == 4Gb of data...)
+ *
+ * - The signature of write_socket has changed, it now simply
+ * returns success=0/failure=nonzero.
+ *
+ * - Trying to get rid of a few warnings --with-debug on
+ * Windows, I've introduced a new type "jb_socket". This is
+ * used for the socket file descriptors. On Windows, this
+ * is SOCKET (a typedef for unsigned). Everywhere else, it's
+ * an int. The error value can't be -1 any more, so it's
+ * now JB_INVALID_SOCKET (which is -1 on UNIX, and in
+ * Windows it maps to the #define INVALID_SOCKET.)
+ *
+ * - The signature of bind_port has changed.
+ *
* Revision 1.24 2002/03/07 03:51:36 oes
* - Improved handling of failed DNS lookups
* - Fixed compiler warnings etc
#if defined(__EMX__) || defined (__OS2__)
#include <sys/select.h> /* OS/2/EMX needs a little help with select */
+#ifdef __OS2__
#include <nerrno.h>
#endif
+#endif
#endif
* nonzero on error.
*
*********************************************************************/
-int write_socket(jb_socket fd, const char *buf, int len)
+int write_socket(jb_socket fd, const char *buf, size_t len)
{
if (len == 0)
{
log_error(LOG_LEVEL_LOG, "%N", len, buf);
-#if defined(_WIN32) || defined(__BEOS__) || defined(AMIGA)
+#if defined(_WIN32)
+ return (send(fd, buf, (int)len, 0) != (int)len);
+#elif defined(__BEOS__) || defined(AMIGA)
return (send(fd, buf, len, 0) != len);
#elif defined(__OS2__)
/*
return(0);
}
-#if defined(_WIN32) || defined(__BEOS__) || defined(AMIGA) || defined(__OS2__)
+#if defined(_WIN32)
return(recv(fd, buf, len, 0));
+#elif defined(__BEOS__) || defined(AMIGA) || defined(__OS2__)
+ return(recv(fd, buf, (size_t)len, 0));
#else
- return(read(fd, buf, len));
+ return(read(fd, buf, (size_t)len));
#endif
}
struct sockaddr_in client, server;
struct hostent *host = NULL;
jb_socket afd;
+#ifdef _WIN32
+ /* Microsoft wierdness - fix a warning. */
+ int c_length, s_length;
+#else
size_t c_length, s_length;
+#endif
#if defined(HAVE_GETHOSTBYADDR_R_8_ARGS) || defined(HAVE_GETHOSTBYADDR_R_7_ARGS) || defined(HAVE_GETHOSTBYADDR_R_5_ARGS)
struct hostent result;
#if defined(HAVE_GETHOSTBYADDR_R_5_ARGS)