2 #include <sys/socket.h> 3 #include <netinet/in.h> 18 struct sockaddr_in sin;
25 x = (
char *) &sin.sin_port;
26 x[1] = port; port >>= 8; x[0] = port;
27 sin.sin_family = AF_INET;
33 if (connect(s,(
struct sockaddr *) &sin,
sizeof(sin)) == 0) {
41 tv.tv_sec =
timeout; tv.tv_usec = 0;
43 if (select(s + 1,(fd_set *) 0,&wfds,(fd_set *) 0,&tv) == -1)
return -1;
44 if (FD_ISSET(s,&wfds)) {
47 if (getpeername(s,(
struct sockaddr *) &sin,&dummy) == -1) {
62 struct sockaddr_in6 sin;
68 sin.sin6_port = htons(port);
69 sin.sin6_family = AF_INET6;
76 if (connect(s,(
struct sockaddr *) &sin,
sizeof(sin)) == 0) {
84 tv.tv_sec =
timeout; tv.tv_usec = 0;
86 if (select(s + 1,(fd_set *) 0,&wfds,(fd_set *) 0,&tv) == -1)
return -1;
87 if (FD_ISSET(s,&wfds)) {
90 if (getpeername(s,(
struct sockaddr *) &sin,&dummy) == -1) {
int timeoutconn(int s, struct ip_address *ip, unsigned int port, int timeout)
void byte_copy(char *, unsigned int, char *)
int timeoutconn46(int fd, struct ip_mx *ix, int port, int timeout)
uint32 socket_getifidx(const char *ifname)
int timeoutconn6(int s, struct ip6_address *ip, unsigned int port, int timeout, char *ifname)
void byte_zero(char *, unsigned int)