Hi.
I'm trying to bind a socket to a certain port on all my local interfaces,
so I check which function can I use to construct apr_sockaddr_t address to
which bind my socket.
>From the manual I found:
---
apr_status_t apr_sockaddr_info_get (
apr_sockaddr_t ** sa,
const char * hostname,
apr_int32_t family,
apr_port_t port,
apr_int32_t flags,
apr_pool_t * p
)
----
Create apr_sockaddr_t from hostname, address family, and port
---
It look like that this function is used to initialize and construct
apr_sockaddr_t variable. So I use:
---
apr_sockaddr_t *sa=NULL;
...
apr_sockaddr_info_get(
&sa,
APR_ANYADDR,
APR_INET,
20000,
APR_IPV4_ADDR_OK,
my_pool
);
...
apr_bind(apr_sock, sa);
---
But this doesn't work. After this function call sa on Linux platform
always points to NULL, on Windows it points where it was pointing prior
function call. I'm using a CVS snapshoot of the APR library.
Is this an error in the APR soucer or in the manual?
I'm now using the below code to construct apr_sockaddr_t:
---
apr_socket_addr_get(&sa, APR_LOCAL, apr_sock);
apr_sockaddr_port_set(sa, PORT);
apr_sockaddr_ip_set(sa, APR_ANYADDR);
---
Is there any more 'elegant' way to do this?
I also have one question which isn't related to the above problem. I post
a mail with a problem linking my program with the APR library some days
ago. I then realized that if I build a dynamic library, my application
works fine, whiles when I try to construct a static library I can't link
my application.
Also any sugestion for this?
Regards,
Dezo