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>
89 fd = socket(AF_INET, SOCK_STREAM, 0);
118 struct hostent* hp = gethostbyname(address.c_str());
122 struct sockaddr_in sa;
124 memset (&sa,
'\0',
sizeof(sa));
125 sa.sin_family = hp->h_addrtype;
126 sa.sin_port = htons(port);
127 memcpy( &sa.sin_addr, hp->h_addr, hp->h_length );
129 if (::
connect(d, (
struct sockaddr*)&sa, (socklen_t)
sizeof(sa)) != -1)
148 struct sockaddr_in addr;
150 memset (&addr,
'\0',
sizeof(addr));
151 addr.sin_family = AF_INET;
152 addr.sin_port = htons(port);
153 addr.sin_addr.s_addr = htonl(INADDR_ANY);
155 if ( bind(d, (
struct sockaddr*)&addr,
sizeof(addr)) != -1 )
174 struct timeval tv, *ptv;
177 if ( time_limit < 0 )
181 tv.tv_sec = time_limit;
190 select( d+1, &fds, NULL, NULL, ptv );
192 return FD_ISSET( d, &fds );
225 return fstat(d, &buf) == 0;
230 typedef socket_traits_unix socket_traits;
233 #endif // __CLAW_SOCKET_TRAITS_UNIX_HPP__