1 /* #included into both socket-client.c and socket-server.c */
3 static const char *unix_socket_address_types[] = {
12 socket_address_to_string (GSocketAddress *address)
16 if (G_IS_INET_SOCKET_ADDRESS (address))
18 GInetAddress *inet_address;
22 inet_address = g_inet_socket_address_get_address (G_INET_SOCKET_ADDRESS (address));
23 str = g_inet_address_to_string (inet_address);
24 port = g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (address));
25 res = g_strdup_printf ("%s:%d", str, port);
28 else if (G_IS_UNIX_SOCKET_ADDRESS (address))
30 GUnixSocketAddress *uaddr = G_UNIX_SOCKET_ADDRESS (address);
32 res = g_strdup_printf ("%s:%s",
33 unix_socket_address_types[g_unix_socket_address_get_address_type (uaddr)],
34 g_unix_socket_address_get_path (uaddr));
41 socket_address_from_string (const char *name)
45 for (i = 0; i < G_N_ELEMENTS (unix_socket_address_types); i++)
47 len = strlen (unix_socket_address_types[i]);
48 if (!strncmp (name, unix_socket_address_types[i], len) &&
51 return g_unix_socket_address_new_with_type (name + len + 1, -1,
52 (GUnixSocketAddressType)i);