[PHP-DEV] Re: getsockname() semantics From: Stig Venaas (Stig.Venaas <email protected>)
Date: 09/23/00

On Sat, Sep 23, 2000 at 09:14:50PM +0200, Sascha Schumann wrote:
> This reminds me of some ugliness in the sockets' extension
> code.

Yes, there are some other ugly stuff there too.

> The code uses getsockname() to determine the address family
> of the socket. It passes a pointer to a sockaddr structure to

It checks the family to determine if it's AF_INET or AF_UNIX.
If I on FreeBSD, Digital Unix or IRIX create an AF_UNIX socket
and immediately call getsockname, I don't get AF_UNIX as the
family.

I think we might need to store the type internally when the socket
is created.

> getsockname() under the assumption that the sockaddr
> structure is large enough to accommodate all supported
> protocol-specific address structures. This assumption is
> false.

If we store it internally, we can avoid getsockname().

> The right way to do this is to use the sockaddr_storage
> structure. If that structure is not available, fall back to
> the sockaddr structure for compatibility with existing
> implementations.

What about falling back to sockaddr_un?

Stig

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>