+2 votes

I have been trying to create a simple app in Godot (my first ever) that sends raw UDP packets on button press. It works fine on desktop, but not on Android (connected to same wifi).

The put_packet() functions seems to return mysterious error code 1 on Android. What does that mean?

Here's the script:

var udp = PacketPeerUDP.new();
var data = RawArray()

func _ready():
    # Called every time the node is added to the scene.
    # Initialization here
    udp.set_send_address("192.168.1.84", 16001) 

    data.push_back(0)
    data.push_back(0)
    data.push_back(0)
    data.push_back(0)


func _on_left_button_pressed():

    data.set(0,1)

    var err = udp.put_packet(data)
    if(err == OK):
        get_node("TitleLabel").set_text("left")
    else:
        get_node("TitleLabel").set_text("Error: " + str(err))   

Where are these errors codes documented? I took a quick look at Godot source code, but didn't find them there either..

in Engine by (71 points)

I found the posix packet peer udp source code and it seems that error code 1 means "generic fail error", which isn't very helpful..

Any ideas on how I can debug this further?

Did you try other ports? Or maybe the netmask is blocking?

In ┬┤drivers/unix/packetpeerudp_posix.cpp┬┤ the relevant stuff hapens.
So either socket() or sento() seems to return -1.
Unfortunately godot doesn't observe errno which is set by these functions.

Without editing the source code to look up errno and recompiling you won't find out what went wrong...

I haven't tried other ports, but I don't think this is a network problem, because UDP packets sent by "UDP sender" app from the same phone to same address/port work just fine.

1 Answer

0 votes
Best answer

You can find the errors in Script -> Search Help -> Type the word "Error" -> @Global Scope but your Error tells nothing "FAILED = 1 Generic fail return error."

Have you enabled the permissions for Internet on Android export?

by (175 points)
selected by

I had not, that fixed it. Thanks!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.