addr = (struct sockaddr *)a;
addr = (struct sockaddr *)&a;
Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, int address_family){    int s;#ifndef NO_IPV6    struct addrinfo hints, *ai;    char portstr[6];    struct sockaddr_in6 a6;#endif    struct sockaddr *addr;    int addrlen;    struct sockaddr_in a;    Actual_Socket ret;    int retcode;    int on = 1;    /*     * Create Socket structure.     */    ret = snew(struct Socket_tag);    ret->fn = &tcp_fn_table;    ret->error = NULL;    ret->plug = plug;    bufchain_init(&ret->output_data);    ret->writable = 0;		       /* to start with */    ret->sending_oob = 0;    ret->frozen = 0;    ret->frozen_readable = 0;    ret->localhost_only = local_host_only;    ret->pending_error = 0;    ret->oobpending = FALSE;    ret->listener = 1;    ret->addr = NULL;    /*     * Translate address_family from platform-independent constants     * into local reality.     */    address_family = (address_family == ADDRTYPE_IPV4 ? AF_INET :		      address_family == ADDRTYPE_IPV6 ? AF_INET6 : AF_UNSPEC);#ifndef NO_IPV6    /* Let's default to IPv6.     * If the stack doesn't support IPv6, we will fall back to IPv4. */    if (address_family == AF_UNSPEC) address_family = AF_INET6;#else    /* No other choice, default to IPv4 */    if (address_family == AF_UNSPEC)  address_family = AF_INET;#endif    /*     * Open socket.     */    s = socket(address_family, SOCK_STREAM, 0);    /* If the host doesn't support IPv6 try fallback to IPv4. */    if (s < 0 && address_family == AF_INET6) {    	address_family = AF_INET;    	s = socket(address_family, SOCK_STREAM, 0);    }    if (s < 0) {	ret->error = strerror(errno);	return (Socket) ret;    }    ret->oobinline = 0;    setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(on));    retcode = -1;    addr = NULL; addrlen = -1;         /* placate optimiser */    if (srcaddr != NULL) {#ifndef NO_IPV6        hints.ai_flags = AI_NUMERICHOST;        hints.ai_family = address_family;        hints.ai_socktype = SOCK_STREAM;        hints.ai_protocol = 0;        hints.ai_addrlen = 0;        hints.ai_addr = NULL;        hints.ai_canonname = NULL;        hints.ai_next = NULL;	assert(port >= 0 && port <= 99999);        sprintf(portstr, "%d", port);        retcode = getaddrinfo(srcaddr, portstr, &hints, &ai);	if (retcode == 0) {	    addr = ai->ai_addr;	    addrlen = ai->ai_addrlen;	}#else        memset(&a,'\0',sizeof(struct sockaddr_in));        a.sin_family = AF_INET;        a.sin_port = htons(port);        a.sin_addr.s_addr = inet_addr(srcaddr);        if (a.sin_addr.s_addr != (in_addr_t)(-1)) {            /* Override localhost_only with specified listen addr. */            ret->localhost_only = ipv4_is_loopback(a.sin_addr);            got_addr = 1;        }        addr = (struct sockaddr *)a;        addrlen = sizeof(a);        retcode = 0;#endif    }    if (retcode != 0) {#ifndef NO_IPV6        if (address_family == AF_INET6) {            memset(&a6,'\0',sizeof(struct sockaddr_in6));            a6.sin6_family = AF_INET6;            a6.sin6_port = htons(port);            if (local_host_only)                a6.sin6_addr = in6addr_loopback;            else                a6.sin6_addr = in6addr_any;            addr = (struct sockaddr *)&a6;            addrlen = sizeof(a6);        } else#endif        {            memset(&a,'\0',sizeof(struct sockaddr_in));            a.sin_family = AF_INET;            a.sin_port = htons(port);	    if (local_host_only)		a.sin_addr.s_addr = htonl(INADDR_LOOPBACK);	    else		a.sin_addr.s_addr = htonl(INADDR_ANY);            addr = (struct sockaddr *)&a;            addrlen = sizeof(a);        }    }    retcode = bind(s, addr, addrlen);    if (retcode < 0) {        close(s);	ret->error = strerror(errno);	return (Socket) ret;    }    if (listen(s, SOMAXCONN) < 0) {        close(s);	ret->error = strerror(errno);	return (Socket) ret;    }    ret->s = s;    uxsel_tell(ret);    add234(sktree, ret);    return (Socket) ret;}