30 #ifndef __CLAW_SOCKET_TRAITS_WIN32_HPP__
31 #define __CLAW_SOCKET_TRAITS_WIN32_HPP__
33 #include <sys/types.h>
67 version = MAKEWORD( 2, 2 );
69 return WSAStartup( version, &data ) == 0;
79 return WSACleanup() == 0;
91 fd = socket(AF_INET, SOCK_STREAM, 0);
104 return ::closesocket(d) == 0;
120 struct hostent* hp = gethostbyname(address.c_str());
124 struct sockaddr_in sa;
126 memset (&sa,
'\0',
sizeof(sa));
127 sa.sin_family = hp->h_addrtype;
128 sa.sin_port = htons(port);
129 memcpy( &sa.sin_addr, hp->h_addr, hp->h_length );
131 if ( ::
connect(d, (
struct sockaddr*)&sa,
sizeof(sa)) != SOCKET_ERROR )
150 struct sockaddr_in addr;
152 memset (&addr,
'\0',
sizeof(addr));
153 addr.sin_family = AF_INET;
154 addr.sin_port = htons(port);
155 addr.sin_addr.s_addr = htonl(INADDR_ANY);
157 if ( bind(d, (
struct sockaddr*)&addr,
sizeof(addr)) != SOCKET_ERROR )
176 struct timeval tv, *ptv;
179 if ( time_limit < 0 )
183 tv.tv_sec = time_limit;
192 select( d+1, &fds, NULL, NULL, ptv );
194 return FD_ISSET( d, &fds );
230 typedef socket_traits_win32 socket_traits;
233 #endif // __CLAW_SOCKET_TRAITS_WIN32_HPP__