* in the BSD sockets API. This is an abstract class; use
* #GInetSocketAddress for internet sockets, or #GUnixSocketAddress
* for UNIX domain sockets.
- **/
+ */
/**
* GSocketAddress:
*
* A socket endpoint address, corresponding to <type>struct sockaddr</type>
* or one of its subtypes.
- **/
+ */
enum
{
P_("The family of the socket address"),
G_TYPE_SOCKET_FAMILY,
G_SOCKET_FAMILY_INVALID,
- G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NAME));
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
}
static void
* g_socket_address_to_native().
*
* Returns: the size of the native <type>struct sockaddr</type> that
- * @address represents
+ * @address represents
*
* Since: 2.22
*/
* <type>struct sockaddr</type>.
* @destlen: the size of @dest. Must be at least as large as
* g_socket_address_get_native_size().
+ * @error: #GError for error reporting, or %NULL to ignore.
*
* Converts a #GSocketAddress to a native <type>struct
* sockaddr</type>, which can be passed to low-level functions like
* connect() or bind().
*
- * Returns: %TRUE if @dest was filled in, %FALSE if @address is invalid
- * or @destlen is too small.
+ * If not enough space is availible, a %G_IO_ERROR_NO_SPACE error is
+ * returned. If the address type is not known on the system
+ * then a %G_IO_ERROR_NOT_SUPPORTED error is returned.
+ *
+ * Returns: %TRUE if @dest was filled in, %FALSE on error
*
* Since: 2.22
*/
gboolean
-g_socket_address_to_native (GSocketAddress *address,
- gpointer dest,
- gsize destlen)
+g_socket_address_to_native (GSocketAddress *address,
+ gpointer dest,
+ gsize destlen,
+ GError **error)
{
g_return_val_if_fail (G_IS_SOCKET_ADDRESS (address), FALSE);
- return G_SOCKET_ADDRESS_GET_CLASS (address)->to_native (address, dest, destlen);
+ return G_SOCKET_ADDRESS_GET_CLASS (address)->to_native (address, dest, destlen, error);
}
/**
{
struct sockaddr_un *addr = (struct sockaddr_un *) native;
+ if (addr->sun_path[0] == 0)
+ return g_unix_socket_address_new_abstract (addr->sun_path+1,
+ sizeof (addr->sun_path) - 1);
return g_unix_socket_address_new (addr->sun_path);
}
#endif