Skip to content

Commit b1d4094

Browse files
committed
Broadcast fix
1 parent aa74947 commit b1d4094

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Drone/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def reconnect(t=2):
4040
print("Waiting for connection, attempt", attempt_count)
4141
try:
4242
clientSocket = socket.socket()
43-
clientSocket.settimeout(3)
43+
# clientSocket.settimeout(3)
4444
clientSocket.connect((host, port))
4545
connected = True
4646
print("Connection successful")

Server/server.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ def auto_connect():
3737
Client.clients[addr[0]].connect(c, addr)
3838

3939

40-
def ip_broadcast(ip):
40+
def ip_broadcast(ip, port):
4141
ip = ip
4242
broadcast_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
4343
broadcast_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
4444
broadcast_sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
4545
while True:
46-
msg = bytes(Client.form_command("server_ip ", ip), "UTF-8")
46+
msg = bytes(Client.form_command("server_ip ", ip, ), "UTF-8")
4747
broadcast_sock.sendto(msg, ('255.255.255.255', 8181)) #TODO to config
48+
print("Broadcast sent")
4849
time.sleep(5)
4950

5051

@@ -325,6 +326,7 @@ def gui_update():
325326
autoconnect_thread.start()
326327

327328
broadcast_thread = threading.Thread(target=ip_broadcast, args=(ip, port, ))
329+
broadcast_thread.start()
328330

329331
if __name__ == '__main__':
330332
try:

0 commit comments

Comments
 (0)