return -1;
}
+ set_nonblocking(res);
+
return res;
}
****************************************************************************/
int is_a_socket(int fd)
{
- int v,l;
- l = sizeof(int);
- return(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&v, &l) == 0);
+ int v,l;
+ l = sizeof(int);
+ return(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&v, &l) == 0);
}
if (fork()==0) {
close(s);
+ set_nonblocking(fd);
+
_exit(fn(fd));
}
struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
int length = sizeof(sa);
static char addr_buf[100];
+ static int initialised;
+
+ if (initialised) return addr_buf;
+
+ initialised = 1;
if (getpeername(fd, &sa, &length)) {
exit_cleanup(1);
}
-
+
strlcpy(addr_buf,(char *)inet_ntoa(sockin->sin_addr), sizeof(addr_buf)-1);
-
return addr_buf;
}
struct hostent *hp;
char **p;
char *def = "UNKNOWN";
+ static int initialised;
+
+ if (initialised) return name_buf;
+
+ initialised = 1;
strcpy(name_buf,def);