UDP connect: Can't assign requested address or "how to determine the outgoing IP address?"

Edwin Groothuis edwin at mavetju.org
Wed Oct 22 20:06:08 PDT 2003


On Wed, Oct 22, 2003 at 07:53:10PM -0700, Lev Walkin wrote:
> Everything's fine apart from one thing: connect() does not like to
> connect to places with destination port equal to zero.

> /*
>  * This will do. Note that it assumes AF_INET.
>  */
> ((struct sockaddr_in *)res->ai_addr)->sin_port = htons(80);

Many many many thanks for this! You're a champ!

Edwin, will never forgot this lesson.

-- 
Edwin Groothuis      |            Personal website: http://www.mavetju.org
edwin at mavetju.org    |    Weblog: http://www.mavetju.org/weblog/weblog.php 


More information about the freebsd-net mailing list