![]() |
![]() |
![]() |
libsoup Reference Manual | ![]() |
---|---|---|---|---|
struct SoupAddress; enum SoupAddressFamily; #define SOUP_ADDRESS_ANY_PORT SoupAddress* soup_address_new (const char *name, guint port); SoupAddress* soup_address_new_from_sockaddr (struct sockaddr *sa, int len); SoupAddress* soup_address_new_any (SoupAddressFamily family, guint port); void (*SoupAddressCallback) (SoupAddress *addr, guint status, gpointer data); void soup_address_resolve_async (SoupAddress *addr, SoupAddressCallback callback, gpointer user_data); void soup_address_resolve_async_full (SoupAddress *addr, GMainContext *async_context, SoupAddressCallback callback, gpointer user_data); guint soup_address_resolve_sync (SoupAddress *addr); const char* soup_address_get_name (SoupAddress *addr); struct sockaddr* soup_address_get_sockaddr (SoupAddress *addr, int *len); const char* soup_address_get_physical (SoupAddress *addr); guint soup_address_get_port (SoupAddress *addr);
SoupAddress represents the address of a TCP connection endpoint; both the IP address and the port. (It is somewhat like an object-oriented version of struct sockaddr.)
If libsoup was built with IPv6 support, SoupAddress will allow both IPv4 and IPv6 addresses.
typedef enum { SOUP_ADDRESS_FAMILY_IPV4 = AF_INET, SOUP_ADDRESS_FAMILY_IPV6 = AF_INET6 } SoupAddressFamily;
The supported address families. Note that the
SOUP_ADDRESS_FAMILY_IPV6
constant is available even if libsoup was
built without IPv6 support, but attempting to create an IPv6
address will fail in that case.
#define SOUP_ADDRESS_ANY_PORT 0
This can be passed to any SoupAddress method that expects a port, to indicate that you don't care what port is used.
SoupAddress* soup_address_new (const char *name, guint port);
Creates a SoupAddress from name
and port
. The SoupAddress's IP
address may not be available right away; the caller can call
soup_address_resolve_async()
or soup_address_resolve_sync()
to
force a DNS resolution.
|
a hostname or physical address |
|
a port number |
Returns : |
a SoupAddress |
SoupAddress* soup_address_new_from_sockaddr (struct sockaddr *sa, int len);
Returns a SoupAddress equivalent to sa
(or NULL
if sa
's
address family isn't supported)
|
a pointer to a sockaddr |
|
size of sa
|
Returns : |
the new SoupAddress |
SoupAddress* soup_address_new_any (SoupAddressFamily family, guint port);
Returns a SoupAddress corresponding to the "any" address
for family
(or NULL
if family
isn't supported), suitable for
passing to soup_socket_server_new()
.
|
the address family |
|
the port number (usually SOUP_ADDRESS_ANY_PORT )
|
Returns : |
the new SoupAddress |
void (*SoupAddressCallback) (SoupAddress *addr, guint status, gpointer data);
The callback function passed to soup_address_resolve_async()
.
|
the SoupAddress that was resolved |
|
SOUP_STATUS_OK or SOUP_STATUS_CANT_RESOLVE
|
|
the user data that was passed to
soup_address_resolve_async()
|
void soup_address_resolve_async (SoupAddress *addr, SoupAddressCallback callback, gpointer user_data);
Asynchronously resolves the missing half of addr
. (Its IP address
if it was created with soup_address_new()
, or its hostname if it
was created with soup_address_new_from_sockaddr()
or
soup_address_new_any()
.) callback
will be called when the
resolution finishes (successfully or not).
|
a SoupAddress |
|
callback to call with the result |
|
data for callback
|
void soup_address_resolve_async_full (SoupAddress *addr, GMainContext *async_context, SoupAddressCallback callback, gpointer user_data);
Like soup_address_resolve_async()
, but calls callback
from
the given async_context
.
|
a SoupAddress |
|
the GMainContext to call callback from
|
|
callback to call with the result |
|
data for callback
|
guint soup_address_resolve_sync (SoupAddress *addr);
Synchronously resolves the missing half of addr
, as with
soup_address_resolve_async()
.
|
a SoupAddress |
Returns : |
SOUP_STATUS_OK or SOUP_STATUS_CANT_RESOLVE
|
const char* soup_address_get_name (SoupAddress *addr);
Returns the hostname associated with addr
.
|
a SoupAddress |
Returns : |
the hostname, or NULL if it is not known.
|
struct sockaddr* soup_address_get_sockaddr (SoupAddress *addr, int *len);
Returns the sockaddr associated with addr
, with its length in
*len
. If the sockaddr is not yet known, returns NULL
.
|
a SoupAddress |
|
return location for sockaddr length |
Returns : |
the sockaddr, or NULL
|
const char* soup_address_get_physical (SoupAddress *addr);
Returns the physical address associated with addr
as a string.
(Eg, "127.0.0.1"). If the address is not yet known, returns NULL
.
|
a SoupAddress |
Returns : |
the physical address, or NULL
|
guint soup_address_get_port (SoupAddress *addr);
Returns the port associated with addr
.
|
a SoupAddress |
Returns : |
the port |
void user_function (SoupAddress *addr, gint status, gpointer user_data) : Run First
Emitted when an address resolution completes. (This is used
internally by soup_address_resolve_async()
itself.)
|
the SoupAddress |
|
the DNS status code |
|
user data set when the signal handler was connected. |