libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] using MHD_CONNECTION_INFO_CLIENT_ADDRESS


From: Christian Grothoff
Subject: Re: [libmicrohttpd] using MHD_CONNECTION_INFO_CLIENT_ADDRESS
Date: Thu, 27 Jan 2011 10:02:38 +0100
User-agent: KMail/1.13.5 (Linux/2.6.32-trunk-vserver-amd64; KDE/4.4.5; x86_64; ; )

On Wednesday 26 January 2011 20:25:06 Eivind Sarto wrote:
> Christian,
> 
> MHD_get_connection_info(conn, MHD_CONNECTION_INFO_CLIENT_ADDRESS) currently
> returns a (struct sockaddr_in **).
> 
> Is that really what you intended?
> Shouldn't just return the connection->addr, instead of &connection->addr ?
> 
> -eivind

Dear Eivind, 

This is intentional and correct.  I've updated the documentation to clarify a 
bit:

address@hidden MHD_CONNECTION_INFO_CLIENT_ADDRESS
+Returns information about the address of the client.  Returns 
+essentially a @code{struct sockaddr **} (since the API returns
+a @code{union MHD_ConnectionInfo *} and that union contains
+a @code{struct sockaddr *}).


So the function is decared to return a pointer (!) to the "union 
MHD_ConnectionInfo", and that union contains another pointer to the struct 
sockaddr.  So in effect, we need a double-pointer and you'll get to the data 
using:

struct sockaddr *so;

so = MHD_get_connection_info (conn,
        MHD_CONNECTION_INFO_CLIENT_ADDRESS)->client_addr;


However, there was one real issue, which is that the union was declared to 
contain a 'struct sockaddr_in *', which is not correct since the API may 
return an IPv6 address as well, so it should be 'struct sockaddr *' instead.

I've fixed that in SVN 14274.

Happy hacking!

Christian





reply via email to

[Prev in Thread] Current Thread [Next in Thread]