56 lines
1.5 KiB
Diff
56 lines
1.5 KiB
Diff
--- a/libjaylink/discovery_tcp.c
|
|
+++ b/libjaylink/discovery_tcp.c
|
|
@@ -228,7 +228,11 @@ static struct jaylink_device *probe_device(struct jaylink_context *ctx,
|
|
JAYLINK_PRIV int discovery_tcp_scan(struct jaylink_context *ctx)
|
|
{
|
|
int ret;
|
|
+#ifdef _WIN32
|
|
+ SOCKET sock;
|
|
+#else
|
|
int sock;
|
|
+#endif
|
|
int opt_value;
|
|
fd_set rfds;
|
|
struct sockaddr_in addr;
|
|
@@ -241,7 +245,7 @@ JAYLINK_PRIV int discovery_tcp_scan(struct jaylink_context *ctx)
|
|
|
|
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
|
|
|
- if (sock < 0) {
|
|
+ if (sock == INVALID_SOCKET) {
|
|
log_err(ctx, "Failed to create discovery socket.");
|
|
return JAYLINK_ERR;
|
|
}
|
|
--- a/libjaylink/transport_tcp.c
|
|
+++ b/libjaylink/transport_tcp.c
|
|
@@ -231,7 +231,11 @@ JAYLINK_PRIV int transport_tcp_open(struct jaylink_device_handle *devh)
|
|
struct jaylink_device *dev;
|
|
struct addrinfo hints;
|
|
struct addrinfo *info;
|
|
+#ifdef _WIN32
|
|
+ SOCKET sock;
|
|
+#else
|
|
int sock;
|
|
+#endif
|
|
|
|
dev = devh->dev;
|
|
ctx = dev->ctx;
|
|
@@ -264,7 +268,7 @@ JAYLINK_PRIV int transport_tcp_open(struct jaylink_device_handle *devh)
|
|
for (struct addrinfo *rp = info; rp != NULL; rp = rp->ai_next) {
|
|
sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
|
|
|
|
- if (sock < 0)
|
|
+ if (sock == INVALID_SOCKET)
|
|
continue;
|
|
|
|
if (!connect(sock, info->ai_addr, info->ai_addrlen))
|
|
@@ -276,7 +280,7 @@ JAYLINK_PRIV int transport_tcp_open(struct jaylink_device_handle *devh)
|
|
|
|
freeaddrinfo(info);
|
|
|
|
- if (sock < 0) {
|
|
+ if (sock == INVALID_SOCKET) {
|
|
log_err(ctx, "Failed to open device.");
|
|
cleanup_handle(devh);
|
|
return JAYLINK_ERR;
|