Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 06 Apr 2010 10:41:43 -0700
From:      Chuck Swiger <cswiger@mac.com>
To:        serena zanetta <sz3003@gmail.com>
Cc:        freebsd-net@freebsd.org
Subject:   Re: Send "connect" control message
Message-ID:  <7FBEC12F-B609-4413-878E-DC5434A02572@mac.com>
In-Reply-To: <s2qb2ecfd381004060832oe4eaef4bp6fea1d4381590dcb@mail.gmail.com>
References:  <s2qb2ecfd381004060832oe4eaef4bp6fea1d4381590dcb@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi--

On Apr 6, 2010, at 8:32 AM, serena zanetta wrote:
> But first of all, I don't know how I can convert the IP_REMOTE, which is
> currently IP_REMOTE = "10.0.0.90", into a in_addr structure...

To convert a string to an IP address kept as an in_addr, you want inet_aton(), used like so:

    const char *ipstr = "127.0.0.1";
    struct in_addr ip;

    if (!inet_aton(ipstr, &ip))
        errx(1, "can't parse IP address %s", ipstr);

[ Example borrowed from "man gethostbyaddr" ]

Regards,
-- 
-Chuck




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7FBEC12F-B609-4413-878E-DC5434A02572>