32 #define YAZ_INVALID_SOCKET INVALID_SOCKET
34 #define YAZ_INVALID_SOCKET -1
39 #include <netinet/in.h>
45 #include <arpa/inet.h>
47 #if HAVE_NETINET_TCP_H
48 #include <netinet/tcp.h>
51 #include <sys/select.h>
55 #include <netinet/in.h>
61 #include <arpa/inet.h>
63 #if HAVE_NETINET_TCP_H
64 #include <netinet/tcp.h>
68 #define YAZ_SOCKLEN_T int
91 unsigned long tru = 1;
92 if (ioctlsocket(s, FIONBIO, &tru))
95 if (fcntl(s, F_SETFL, O_NONBLOCK))
108 WORD wVersionRequested = MAKEWORD(2, 0);
109 if (WSAStartup( wVersionRequested, &wsaData))
123 struct sockaddr_in add;
124 struct sockaddr *addr = 0;
126 struct sockaddr caddr;
131 p->
m_socket = socket(AF_INET, SOCK_STREAM, 0);
141 unsigned long one = 1;
142 if (setsockopt(p->
m_socket, SOL_SOCKET, SO_REUSEADDR, (
char*)
153 add.sin_family = AF_INET;
154 add.sin_port = htons(port_to_use);
155 add.sin_addr.s_addr = INADDR_ANY;
156 addr = (
struct sockaddr *) &add;
158 if (bind(p->
m_socket, addr,
sizeof(
struct sockaddr_in)))
175 tmpadd = (unsigned) inet_addr(
"127.0.0.1");
184 memcpy(&add.sin_addr.s_addr, &tmpadd,
sizeof(
struct in_addr));
185 p->
m_fd[1] = socket(AF_INET, SOCK_STREAM, 0);
195 if (connect(p->
m_fd[1], addr,
sizeof(*addr)))
199 WSAGetLastError() != WSAEWOULDBLOCK
224 FD_SET(p->
m_fd[1], &write_set);
225 if (select(p->
m_fd[1]+1, 0, &write_set, 0, 0) != 1)
Header for errno utilities.
Header for Nibble Memory functions.
int yaz_spipe_get_read_fd(yaz_spipe_t p)
returns reading socket
yaz_spipe_t yaz_spipe_create(int port_to_use, WRBUF *err_msg)
create socket pipe
#define YAZ_INVALID_SOCKET
static void yaz_spipe_close(int *fd)
void yaz_spipe_destroy(yaz_spipe_t p)
destroys socket pipe
int yaz_spipe_get_write_fd(yaz_spipe_t p)
returns writing socket
static int nonblock(int s)
void wrbuf_printf(WRBUF b, const char *fmt,...)
writes printf result to WRBUF
Header for memory handling functions.
#define xfree(x)
utility macro which calls xfree_f
#define xmalloc(x)
utility macro which calls malloc_f
Header with fundamental macros.