30 #ifndef __CLAW_SOCKET_TRAITS_UNIX_HPP__
31 #define __CLAW_SOCKET_TRAITS_UNIX_HPP__
33 #include <sys/types.h>
34 #include <sys/socket.h>
36 #include <netinet/in.h>
37 #include <netinet/tcp.h>
90 fd = socket(AF_INET, SOCK_STREAM, 0);
119 struct hostent* hp = gethostbyname(address.c_str());
123 struct sockaddr_in sa;
125 memset (&sa,
'\0',
sizeof(sa));
126 sa.sin_family = hp->h_addrtype;
127 sa.sin_port = htons(port);
128 memcpy( &sa.sin_addr, hp->h_addr, hp->h_length );
130 if (::
connect(d, (
struct sockaddr*)&sa, (socklen_t)
sizeof(sa)) != -1)
149 struct sockaddr_in addr;
151 memset (&addr,
'\0',
sizeof(addr));
152 addr.sin_family = AF_INET;
153 addr.sin_port = htons(port);
154 addr.sin_addr.s_addr = htonl(INADDR_ANY);
156 if ( bind(d, (
struct sockaddr*)&addr,
sizeof(addr)) != -1 )
175 struct timeval tv, *ptv;
178 if ( time_limit < 0 )
182 tv.tv_sec = time_limit;
191 select( d+1, &fds, NULL, NULL, ptv );
193 return FD_ISSET( d, &fds );
226 return fstat(d, &buf) == 0;
231 typedef socket_traits_unix socket_traits;
234 #endif // __CLAW_SOCKET_TRAITS_UNIX_HPP__