Skip to content

Commit

Permalink
FIx assertion print and socket creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Flova committed Jan 17, 2024
1 parent b6ca74e commit e9e7e6c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions game_controller_hl/game_controller_hl/receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ def __init__(self, *args, **kwargs):

def _open_socket(self) -> socket.socket:
""" Creates the socket """
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.socket.bind(self.addr)
self.socket.settimeout(2)
new_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
new_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
new_socket.bind(self.addr)
new_socket.settimeout(2)
return new_socket

def receive_forever(self):
""" Waits in a loop for new packages """
Expand Down Expand Up @@ -119,7 +120,7 @@ def receive_and_answer_once(self):
self.answer_to_gamecontroller(peer)

except AssertionError as ae:
self.get_logger().error(ae)
self.get_logger().error(str(ae))
except socket.timeout:
self.get_logger().info("No GameController message received (socket timeout)", throttle_duration_sec=5)
except ConstError:
Expand Down

0 comments on commit e9e7e6c

Please sign in to comment.