Esempio n. 1
0
static bool
get_tcp_connect_by_host(int sd, const char *host, short destport,
			GError **error_r)
{
	struct sockaddr_in addr;

	return get_sockaddr_by_host(host, destport, &addr, error_r) &&
		get_tcp_connect(sd, addr, error_r);
}
Esempio n. 2
0
int get_tcp_connect_by_host(int sd, char *host, u_int16_t destport)
{
    struct sockaddr_in addr;
    struct hostent *h;

    h = gethostbyname(host);
    if(h) {
        addr.sin_family = h->h_addrtype;
        memcpy((char *) &addr.sin_addr.s_addr, h->h_addr_list[0], h->h_length);
    } else {
        addr.sin_family = AF_INET;
        if((addr.sin_addr.s_addr=inet_addr(host))==0xFFFFFFFF) {
            ERRMSG("gethostbyname: '%s' \n", host);
            return -1;
        }
    }
    addr.sin_port=htons(destport);

    return get_tcp_connect(sd, addr);
}