Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
goldarte committed Mar 7, 2019
2 parents e0803aa + b1d4094 commit 7a1c6f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Drone/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def reconnect(t=2):
print("Waiting for connection, attempt", attempt_count)
try:
clientSocket = socket.socket()
clientSocket.settimeout(3)
# clientSocket.settimeout(3)
clientSocket.connect((host, port))
connected = True
print("Connection successful")
Expand Down
6 changes: 4 additions & 2 deletions Server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ def auto_connect():
Client.clients[addr[0]].connect(c, addr)


def ip_broadcast(ip):
def ip_broadcast(ip, port):
ip = ip
broadcast_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
broadcast_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
broadcast_sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
while True:
msg = bytes(Client.form_command("server_ip ", ip), "UTF-8")
msg = bytes(Client.form_command("server_ip ", ip, ), "UTF-8")
broadcast_sock.sendto(msg, ('255.255.255.255', 8181)) #TODO to config
print("Broadcast sent")
time.sleep(5)


Expand Down Expand Up @@ -325,6 +326,7 @@ def gui_update():
autoconnect_thread.start()

broadcast_thread = threading.Thread(target=ip_broadcast, args=(ip, port, ))
broadcast_thread.start()

if __name__ == '__main__':
try:
Expand Down

0 comments on commit 7a1c6f6

Please sign in to comment.