UDP server side bind fixed

pull/3/head
kaqu 2 years ago
parent b6fc2e001f
commit 26746a515f
  1. 4
      .vscode/launch.json
  2. 5
      game_objects/pong_player.py

@ -9,8 +9,8 @@
"type": "python",
"request": "launch",
"program": "${file}",
//"args": ["--sizeable", "--server"],
"args": ["--sizeable", "--player", "1", "localhost"],
"args": ["--sizeable", "--server"],
//"args": ["--sizeable", "--player", "1", "127.0.0.1"],
//"args": ["--sizeable", "--viewer", "127.0.0.1"],
"console": "integratedTerminal"
}

@ -54,9 +54,8 @@ class PongPlayer:
self.bUseServer = False
if (player_index == 1) and (bThisIsTheServer): # Is this THE server? (But init. only once!)
UDP_PACKET_SIZE = struct.calcsize(pgc.UDP_TRANSFER_FORMAT) # Size of receiver buffer
serverUDP = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP Receiver
#serverUDP.bind(("127.0.0.1", pgc.PANDEMIC_PONG_PORT)) # Localhost
serverUDP.bind(("localhost", pgc.PANDEMIC_PONG_PORT)) # Localhost
serverUDP = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP Receiver
serverUDP.bind(("0.0.0.0", pgc.PANDEMIC_PONG_PORT)) # Whatever local address ...
serverUDP.setblocking(False) # Do not block ...
self.state = pgc.BTN_STATE_NONE # Button mask (as listed above)

Loading…
Cancel
Save