+ if (nd->type == FIO_TYPE_UDP || nd->type == FIO_TYPE_TCP)
+ return fio_netio_setup_connect_inet(td, host, port);
+ else
+ return fio_netio_setup_connect_unix(td, host);
+}
+
+static int fio_netio_setup_listen_unix(struct thread_data *td, const char *path)
+{
+ struct netio_data *nd = td->io_ops->data;
+ struct sockaddr_un *addr = &nd->addr_un;
+ mode_t mode;
+ int len, fd;
+
+ fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (fd < 0) {
+ log_err("fio: socket: %s\n", strerror(errno));
+ return -1;
+ }
+
+ mode = umask(000);
+
+ memset(addr, 0, sizeof(*addr));
+ addr->sun_family = AF_UNIX;
+ strcpy(addr->sun_path, path);
+ unlink(path);
+
+ len = sizeof(addr->sun_family) + strlen(path) + 1;
+
+ if (bind(fd, (struct sockaddr *) addr, len) < 0) {
+ log_err("fio: bind: %s\n", strerror(errno));
+ close(fd);
+ return -1;
+ }
+
+ umask(mode);
+ nd->listenfd = fd;
+ return 0;
+}
+
+static int fio_netio_setup_listen_inet(struct thread_data *td, short port)
+{
+ struct netio_data *nd = td->io_ops->data;
+ int fd, opt, type;
+
+ if (nd->type == FIO_TYPE_TCP)
+ type = SOCK_STREAM;
+ else
+ type = SOCK_DGRAM;
+
+ fd = socket(AF_INET, type, 0);