30 #define YAZ_INVALID_SOCKET INVALID_SOCKET
32 #define YAZ_INVALID_SOCKET -1
37 #include <netinet/in.h>
43 #include <arpa/inet.h>
45 #if HAVE_NETINET_TCP_H
46 #include <netinet/tcp.h>
49 #include <sys/socket.h>
53 #include <netinet/in.h>
59 #include <arpa/inet.h>
61 #if HAVE_NETINET_TCP_H
62 #include <netinet/tcp.h>
85 unsigned long tru = 1;
86 if (ioctlsocket(s, FIONBIO, &tru))
89 if (fcntl(s, F_SETFL, O_NONBLOCK))
102 WORD wVersionRequested = MAKEWORD(2, 0);
103 if (WSAStartup( wVersionRequested, &wsaData))
117 struct sockaddr_in add;
118 struct sockaddr *addr = 0;
120 struct sockaddr caddr;
122 int caddr_len =
sizeof(caddr);
124 socklen_t caddr_len =
sizeof(caddr);
129 p->
m_socket = socket(AF_INET, SOCK_STREAM, 0);
139 unsigned long one = 1;
140 if (setsockopt(p->
m_socket, SOL_SOCKET, SO_REUSEADDR, (
char*)
151 add.sin_family = AF_INET;
152 add.sin_port = htons(port_to_use);
153 add.sin_addr.s_addr = INADDR_ANY;
154 addr = (
struct sockaddr *) &add;
156 if (bind(p->
m_socket, addr,
sizeof(
struct sockaddr_in)))
173 tmpadd = (unsigned) inet_addr(
"127.0.0.1");
182 memcpy(&add.sin_addr.s_addr, &tmpadd,
sizeof(
struct in_addr));
183 p->
m_fd[1] = socket(AF_INET, SOCK_STREAM, 0);
193 if (connect(p->
m_fd[1], addr,
sizeof(*addr)))
197 WSAGetLastError() != WSAEWOULDBLOCK
222 FD_SET(p->
m_fd[1], &write_set);
223 if (select(p->
m_fd[1]+1, 0, &write_set, 0, 0) != 1)