Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot receive UDP packets in Godot 4 Beta 5 #69136

Closed
GK-GreyGhost opened this issue Nov 24, 2022 · 3 comments
Closed

cannot receive UDP packets in Godot 4 Beta 5 #69136

GK-GreyGhost opened this issue Nov 24, 2022 · 3 comments

Comments

@GK-GreyGhost
Copy link
Contributor

Godot version

Godot 4 Beta 5

System information

Windows 10

Issue description

packet message is not received, no errors in Godot 4
packet message is printed in Godot 3.5

Steps to reproduce

  1. send UDP packet to port
  2. Godot 3.5 prints message, Godot 4 doesn't

Minimal reproduction project

udp_demo_godot3_working.zip

udp_demo_4_broken.zip

@Calinou
Copy link
Member

Calinou commented Nov 24, 2022

You may need to update your code to work in Godot 4. As per godotengine/godot-docs#6393:

@GK-GreyGhost
Copy link
Contributor Author

GK-GreyGhost commented Nov 25, 2022

Thank you, I'm sorry, I don't think I understand, the linked documentation only references PacketPeerUDP and not UDPServer, should I only be using PacketPeerUDP even though I don't intend to send packets, only receive?

based on that I tried https://docs.godotengine.org/en/latest/classes/class_packetpeerudp.html#class-packetpeerudp-method-wait

extends Node
var socket = PacketPeerUDP.new()

func _ready():
	
	if socket.bind(4592,"*") != OK:
		print("Failed to bind to port 4592")
		return
	else:
		print('started on port 4592')
		
	while socket.wait() == OK:
		var data = socket.get_packet().get_string_from_ascii()
		print(data)
		if data == "end":
			return

and can't receive any packets

@GK-GreyGhost
Copy link
Contributor Author

documentation has been updated and everything works now, closing, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants