Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Jan 2006 09:16:08 -0500 (EST)
From:      Daniel Eischen <deischen@freebsd.org>
To:        Kurt Miller <lists@intricatesoftware.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: read hang on datagram socket
Message-ID:  <Pine.GSO.4.43.0601270909190.10667-100000@sea.ntplx.net>
In-Reply-To: <200601262340.46999.lists@intricatesoftware.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 26 Jan 2006, Kurt Miller wrote:

> On Thursday 26 January 2006 7:26 pm, Daniel Eischen wrote:
> >
> > The modified version does not hang on 5.2.  Do you have multiple
> > interfaces on your 5.4 box?
>
> No, the 5.4 box is virtually identical to the 6.0 box. I set them both
> up at the same time from initial installs for the project.
>
> truk@freebsd5-4$ ifconfig
> lnc0: flags=108843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
>         inet6 fe80::250:56ff:fe40:451a%lnc0 prefixlen 64 scopeid 0x1
>         inet 172.16.1.36 netmask 0xffffff00 broadcast 172.16.1.255
>         ether 00:50:56:40:45:1a
> lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
>         inet 127.0.0.1 netmask 0xff000000
>         inet6 ::1 prefixlen 128
>         inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2

[ ... ]

> > What happens when you try using non-zero IP addresses and ports?
> >
>
> Setting the ports doesn't effect the problem, however setting the
> addresses does. It really seems like binding to INADDR_ANY only binds
> to loopback address 127.0.0.1 and not all the interfaces.
>
> If sock1 is bound to the hostAddress and sock2 connects to sock1 at
> the hostAddress it works ok. If sock1 is bound to INADDR_ANY and sock2
> connects to sock1 using INADDR_ANY it works. but any mixture of of
> using INADDR_ANY with the hostAddress fails.

According to Steven's Network Programming, when binding to
INADDR_ANY, the operating system doesn't assign an address
until the first write.  This is unlike the port, where using
port 0, an ephemeral port is assigned right away.  I don't
have the book handy right now, so I forgot if the INADDR_ANY
behavior is only when you have multiple interfaces or not.

> Unfortunately, I don't have control over the addresses, the java
> programs do. This particular jck test binds the first socket with
> INADDR_ANY (InetAddress.getByName("0.0.0.0")) and connects the second
> socket to the first using the hostAddress (InetAddress.getLocalHost()).

You can try sending a byte before getting the address for the
port and see if that works.  Do you have anything weird, like
not having a default route (gateway)?

-- 
DE




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.43.0601270909190.10667-100000>