Skip to content

Commit b2caa7e

Browse files
committed
fixed windows support
1 parent 29eb2fb commit b2caa7e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

openrgb/network.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python3
2+
import sys
23
import socket
34
import struct
45
import threading
@@ -7,6 +8,11 @@
78
from time import sleep
89
from enum import Enum
910

11+
if sys.platform.startswith("linux"):
12+
NOSIGNAL = socket.MSG_NOSIGNAL
13+
elif sys.platform.startswith("win"):
14+
NOSIGNAL = 0
15+
1016

1117
class Status(Enum):
1218
WAITING = 1
@@ -38,7 +44,7 @@ def __init__(self, update_callback: Callable, address: str = "127.0.0.1", port:
3844
# Sending the client name
3945
name = bytes(f"{name}\0", 'utf-8')
4046
self.send_header(0, utils.PacketType.NET_PACKET_ID_SET_CLIENT_NAME, len(name))
41-
self.sock.send(name, socket.MSG_NOSIGNAL)
47+
self.sock.send(name, NOSIGNAL)
4248

4349
# Requesting the number of devices
4450
self.send_header(0, utils.PacketType.NET_PACKET_ID_REQUEST_CONTROLLER_COUNT, 0)
@@ -93,7 +99,7 @@ def send_header(self, device_id: int, packet_type: int, packet_size: int):
9399
:param packet_type: a utils.PacketType
94100
:param packet_size: the full size of the data to be send after the header
95101
'''
96-
self.sock.send(struct.pack('ccccIII', b'O', b'R', b'G', b'B', device_id, packet_type, packet_size), socket.MSG_NOSIGNAL)
102+
self.sock.send(struct.pack('ccccIII', b'O', b'R', b'G', b'B', device_id, packet_type, packet_size), NOSIGNAL)
97103

98104
def timeout(self):
99105
while self.state == Status.WAITING:

0 commit comments

Comments
 (0)