inetcat: Make sure to report correct error messages
diff --git a/tools/inetcat.c b/tools/inetcat.c
index c6e0250..220a8a7 100644
--- a/tools/inetcat.c
+++ b/tools/inetcat.c
@@ -252,12 +252,15 @@
fprintf(stderr, "Failed to convert network address: %d (%s)\n", errno, strerror(errno));
}
devfd = socket_connect_addr(saddr, device_port);
+ if (devfd < 0) {
+ devfd = -errno;
+ }
} else if (dev->conn_type == CONNECTION_TYPE_USB) {
devfd = usbmuxd_connect(dev->handle, device_port);
}
free(dev_list);
if (devfd < 0) {
- fprintf(stderr, "Error connecting to device: %s\n", strerror(errno));
+ fprintf(stderr, "Error connecting to device: %s\n", strerror(-devfd));
return 1;
}