Re: getsockname() semantics
| From: | Stig Venaas | Date: | Sat, 23 Sep 2000 20:06:05 +0000 |
| Subject: | Re: getsockname() semantics | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-33611@lists.php.net to get a copy of this message | ||
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