godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.89k stars 20.15k forks source link

create_server does not create LISTEN socket #92367

Open fleimeris opened 3 months ago

fleimeris commented 3 months ago

Tested versions

System information

Godot v4.3.dev6.mono - Fedora Linux 38 (Workstation Edition) - Wayland - Vulkan (Forward+) - dedicated AMD Radeon RX 580 Series (RADV POLARIS10) () - AMD Ryzen 7 3700X 8-Core Processor (16 Threads)

Issue description

CreateServer() does not create a listen socket as it should. I have tried with versions 4.2.2, 4.0, on different computers and on GD only builds, but it concluded with same results. It also returns OK. Therefore I can't connect to the server.

To check what ports are listen I'm running command sudo netstat -tulpn and result of this command is this:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:34861         0.0.0.0:*               LISTEN      13920/godot         
tcp        0      0 127.0.0.1:6006          0.0.0.0:*               LISTEN      13920/godot         
tcp        0      0 127.0.0.1:6007          0.0.0.0:*               LISTEN      13920/godot         
tcp        0      0 127.0.0.1:6005          0.0.0.0:*               LISTEN      13920/godot         
udp6       0      0 :::6969                 :::*                                14069/godot         <------- this should marked as LISTEN

Console is clear and it does not give any errors

Steps to reproduce

  1. Create a new project with a scene
  2. Attach GD script
  3. In _Ready method write this:
    var peer = ENetMultiplayerPeer.new()
    peer.create_server(6969)
    multiplayer.multiplayer_peer = peer
  4. Run project
  5. Check for listen ports

Minimal reproduction project (MRP)

reproduction project.zip

Calinou commented 3 months ago

What's the difference between a standard socket and a LISTEN socket, and why should a LISTEN socket be used?

Note that in the netstat output, the ENetMultiplayerPeer is on IPv6 while others are on IPv4.

fleimeris commented 3 months ago

Sorry, forgot to mention, but I can't connect to that specific port if it's not marked as LISTEN. About IPv6 I did not noticed. Is this intended ?

Oshroth commented 3 months ago

I'm not sure if you can LISTEN on UDP as UDP is stateless. LISTEN to my understanding, is the state used by TCP to allow a server to listen for incoming connections and isn't used with UDP, because a UDP socket is always technically listening