* Copyright (c) 1995-2002, Index Data
* See the file LICENSE for details.
*
- * $Id: tcpip.c,v 1.46 2002-02-19 20:02:40 adam Exp $
+ * $Id: tcpip.c,v 1.50 2002-09-25 12:37:07 adam Exp $
*/
#include <stdio.h>
#define TRC(X)
#endif
+#ifndef YAZ_SOCKLEN_T
+#define YAZ_SOCKLEN_T int
+#endif
+
/* this state is used for both SSL and straight TCP/IP */
typedef struct tcpip_state
{
return 1;
}
#else
- if (errno == EINPROGRESS)
+ if (yaz_errno() == EINPROGRESS)
{
h->event = CS_CONNECT;
h->state = CS_ST_CONNECTING;
void *cd)
{
struct sockaddr_in addr;
-#ifdef __cplusplus
- socklen_t len = sizeof(addr);
-#else
- int len = sizeof(addr);
-#endif
+ YAZ_SOCKLEN_T len = sizeof(addr);
TRC(fprintf(stderr, "tcpip_listen pid=%d\n", getpid()));
if (h->state != CS_ST_IDLE)
#ifdef WIN32
WSAGetLastError() == WSAEWOULDBLOCK
#else
- errno == EWOULDBLOCK
+ yaz_errno() == EWOULDBLOCK
#ifdef EAGAIN
#if EAGAIN != EWOULDBLOCK
- || errno == EAGAIN
+ || yaz_errno() == EAGAIN
#endif
#endif
#endif
else
return -1;
#else
- if (errno == EWOULDBLOCK
+ if (yaz_errno() == EWOULDBLOCK
#ifdef EAGAIN
#if EAGAIN != EWOULDBLOCK
- || errno == EAGAIN
+ || yaz_errno() == EAGAIN
+#endif
#endif
+ || yaz_errno() == EINPROGRESS
+#ifdef __sun__
+ || yaz_errno() == ENOENT /* Sun's sometimes set errno to this */
#endif
- || errno == EINPROGRESS
)
{
h->io_pending = CS_WANT_READ;
break;
}
- else if (errno == 0)
+ else if (yaz_errno() == 0)
continue;
else
return -1;
#ifdef WIN32
WSAGetLastError() == WSAEWOULDBLOCK
#else
- errno == EWOULDBLOCK
+ yaz_errno() == EWOULDBLOCK
#ifdef EAGAIN
#if EAGAIN != EWOULDBLOCK
- || errno == EAGAIN
+ || yaz_errno() == EAGAIN
#endif
#endif
#endif
struct sockaddr_in addr;
tcpip_state *sp = (struct tcpip_state *)h->cprivate;
char *r, *buf = sp->buf;
- size_t len;
+ YAZ_SOCKLEN_T len;
struct hostent *host;
len = sizeof(addr);