fd = socket(src.ss_family, SOCK_STREAM, 0);
fd = socket(res->ai_family, SOCK_STREAM, 0);
static int tcp_bind_to(sa_family_t family, unsigned int flags,                       address *remote, address *local,                        callback *fn, io_stream *prm){	int err, fd, ns;	struct addrinfo hints, *res = NULL;	struct sockaddr_storage src;	assert(remote != NULL);	assert(local != NULL);	assert(local->address != NULL || local->port != NULL);	assert(local->address == NULL || strlen(local->address) > 0);	assert(local->port    == NULL || strlen(local->port) > 0);		assert((flags & USE_UDP) == 0);	 	memset(&hints, 0, sizeof(hints));	hints.ai_family   = family;	hints.ai_flags    = AI_PASSIVE;	hints.ai_socktype = SOCK_STREAM;		if (flags & NUMERIC_MODE) 		hints.ai_flags |= AI_NUMERICHOST;	err = getaddrinfo(local->address, local->port, &hints, &res);	if (err != 0) fatal("getaddrinfo error: %s", gai_strerror(err));			assert(res != NULL);	memcpy(&src, res->ai_addr, res->ai_addrlen);		freeaddrinfo(res);	fd = socket(src.ss_family, SOCK_STREAM, 0);	if (fd < 0) fatal("cannot create the socket: %s", strerror(errno));#ifdef IPV6_V6ONLY	if (family == AF_INET6) {		int on = 1;		/* in case of error, we will go on anyway... */		err = setsockopt(fd,IPPROTO_IPV6,IPV6_V6ONLY,&on,sizeof(on));		if (err < 0) perror("error with sockopt IPV6_V6ONLY");	}#endif 			if (flags & REUSE_ADDR) {		int on = 1;		/* in case of error, we will go on anyway... */		err = setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,&on,sizeof(on));		if (err < 0) perror("error with sockopt SO_REUSEADDR");	}	err = bind(fd, (struct sockaddr *)&src, sizeof(src));	if (err != 0) fatal("cannot use specified source addr/port: %s", 		            strerror(errno));	err = listen(fd, 5);	if (err != 0) fatal("cannot listen on specified addr/port: %s", 		            strerror(errno));	/* enter in the accept loop */ 	for (;;) {		size_t destlen;		struct sockaddr_storage dest;			destlen = sizeof(dest);					ns = accept(fd, (struct sockaddr *)&dest, &destlen);		if (ns < 0) fatal("cannot accept connection: %s", 		                  strerror(errno));		if ((remote->address == NULL && remote->port == NULL) || 		    is_allowed((struct sockaddr*)&dest, remote, flags) == TRUE) {			/* break the loop after first accept if 			 * we're not running in continuos mode */			if (fn == NULL) break;			/* else, if we're running in continuos mode 			 * let's send the results to the callback 			 * function */			else fn(ns, fd, prm);		} else close(ns);	} 		close(fd);		return ns;}