#include <sys/stat.h>
#include <sys/time.h>
#include <sys/ioctl.h>
+#include <sys/un.h>
#include <sys/wait.h>
#ifdef __linux__
"options :\n"
" -v : verbose\n"
" -u : use UDP instead of TCP (limited)\n"
+ " -U : use UNIX instead of TCP (limited, addr must have one '/')\n"
" -t|-tt|-ttt : show time (msec / relative / absolute)\n"
" -e : use epoll instead of poll on Linux\n"
"actions :\n"
memset(ss, 0, sizeof(*ss));
+ /* if there's a slash it's a unix socket */
+ if (strchr(str, '/')) {
+ ((struct sockaddr_un *)ss)->sun_family = AF_UNIX;
+ strncpy(((struct sockaddr_un *)ss)->sun_path, str, sizeof(((struct sockaddr_un *)ss)->sun_path) - 1);
+ ((struct sockaddr_un *)ss)->sun_path[sizeof(((struct sockaddr_un *)ss)->sun_path)] = 0;
+ return 0;
+ }
+
/* look for the addr/port delimiter, it's the last colon. If there's no
* colon, it's 0:<port>.
*/
}
/* Create a new TCP socket for either listening or connecting */
-int tcp_socket()
+int tcp_socket(sa_family_t fam)
{
int sock;
- sock = socket(AF_INET, sock_type, sock_proto);
+ sock = socket(fam, sock_type, sock_proto);
if (sock < 0) {
perror("socket()");
return -1;
if (sock < 0) {
- sock = tcp_socket();
+ sock = tcp_socket(sa->ss_family);
if (sock < 0)
return sock;
}
}
if (sock < 0) {
- sock = tcp_socket();
+ sock = tcp_socket(sa->ss_family);
if (sock < 0)
return sock;
}
sock_type = SOCK_DGRAM;
sock_proto = IPPROTO_UDP;
}
+ else if (strcmp(argv[0], "-U") == 0) {
+ sock_proto = 0;
+ }
else if (strcmp(argv[0], "--") == 0)
break;
else