Add unix sockets

personal/stbuehler/wip
Stefan Bühler 14 years ago
parent 4a8ce0a63f
commit 1e115c522d

@ -567,6 +567,14 @@ sockaddr sockaddr_from_string(GString *str, guint tcp_default_port) {
guint16 port = tcp_default_port;
sockaddr saddr = { 0, NULL };
#ifdef HAVE_SYS_UN_H
if (0 == strncmp(str->str, "unix:/", 6)) {
saddr.len = str->len + 1 + sizeof(saddr.addr->un.sun_family);
saddr.addr = (sock_addr*) g_slice_alloc0(saddr.len);
saddr.addr->un.sun_family = AF_UNIX;
strcpy(saddr.addr->un.sun_path, str->str);
} else
#endif
if (parse_ipv4(str->str, &ipv4, NULL, &port)) {
if (!port) return saddr;
saddr.len = sizeof(struct sockaddr_in);
@ -575,7 +583,8 @@ sockaddr sockaddr_from_string(GString *str, guint tcp_default_port) {
saddr.addr->ipv4.sin_addr.s_addr = ipv4;
saddr.addr->ipv4.sin_port = htons(port);
#ifdef HAVE_IPV6
} else if (parse_ipv6(str->str, ipv6, NULL, &port)) {
} else
if (parse_ipv6(str->str, ipv6, NULL, &port)) {
if (!port) return saddr;
saddr.len = sizeof(struct sockaddr_in6);
saddr.addr = (sock_addr*) g_slice_alloc0(saddr.len);

Loading…
Cancel
Save