Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions core/io/tcp_server.compat.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**************************************************************************/
/* tcp_server.compat.inc */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/

#ifndef DISABLE_DEPRECATED

#include "core/object/class_db.h"

Error TCPServer::_listen_bind_compat_120522(uint16_t p_port, const IPAddress &p_bind_address) {
return listen(p_port, p_bind_address);
}

void TCPServer::_bind_compatibility_methods() {
ClassDB::bind_compatibility_method(D_METHOD("listen", "port", "bind_address"), &TCPServer::_listen_bind_compat_120522, DEFVAL("*"));
}

#endif // DISABLE_DEPRECATED
4 changes: 3 additions & 1 deletion core/io/tcp_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/**************************************************************************/

#include "tcp_server.h"
#include "tcp_server.compat.inc"

#include "core/object/class_db.h"

Expand All @@ -38,9 +39,10 @@ void TCPServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("take_connection"), &TCPServer::take_connection);
}

Error TCPServer::listen(uint16_t p_port, const IPAddress &p_bind_address) {
Error TCPServer::listen(int64_t p_port, const IPAddress &p_bind_address) {
ERR_FAIL_COND_V(_sock.is_null(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock->is_open(), ERR_ALREADY_IN_USE);
ERR_FAIL_COND_V_MSG(p_port < 0 || p_port > 65535, ERR_PARAMETER_RANGE_ERROR, vformat("Can't listen on port %d. The port number must be between 0 and 65535 (inclusive).", p_port));
ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);

Error err;
Expand Down
6 changes: 5 additions & 1 deletion core/io/tcp_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ class TCPServer : public SocketServer {

protected:
static void _bind_methods();
#ifndef DISABLE_DEPRECATED
Error _listen_bind_compat_120522(uint16_t p_port, const IPAddress &p_bind_address = IPAddress("*"));
static void _bind_compatibility_methods();
#endif // DISABLE_DEPRECATED

public:
Error listen(uint16_t p_port, const IPAddress &p_bind_address = IPAddress("*"));
Error listen(int64_t p_port, const IPAddress &p_bind_address = IPAddress("*"));
int get_local_port() const;
Ref<StreamPeerTCP> take_connection();
Ref<StreamPeerSocket> take_socket_connection() override { return take_connection(); }
Expand Down
43 changes: 43 additions & 0 deletions core/io/udp_server.compat.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**************************************************************************/
/* udp_server.compat.inc */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/

#ifndef DISABLE_DEPRECATED

#include "core/object/class_db.h"

Error UDPServer::_listen_bind_compat_120522(uint16_t p_port, const IPAddress &p_bind_address) {
return listen(p_port, p_bind_address);
}

void UDPServer::_bind_compatibility_methods() {
ClassDB::bind_compatibility_method(D_METHOD("listen", "port", "bind_address"), &UDPServer::_listen_bind_compat_120522, DEFVAL("*"));
}

#endif // DISABLE_DEPRECATED
4 changes: 3 additions & 1 deletion core/io/udp_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/**************************************************************************/

#include "udp_server.h"
#include "udp_server.compat.inc"

#include "core/object/class_db.h"

Expand Down Expand Up @@ -99,9 +100,10 @@ Error UDPServer::poll() {
return OK;
}

Error UDPServer::listen(uint16_t p_port, const IPAddress &p_bind_address) {
Error UDPServer::listen(int64_t p_port, const IPAddress &p_bind_address) {
ERR_FAIL_COND_V(_sock.is_null(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock->is_open(), ERR_ALREADY_IN_USE);
ERR_FAIL_COND_V_MSG(p_port < 0 || p_port > 65535, ERR_PARAMETER_RANGE_ERROR, vformat("Can't listen on port %d. The port number must be between 0 and 65535 (inclusive).", p_port));
ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);

Error err;
Expand Down
7 changes: 6 additions & 1 deletion core/io/udp_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,14 @@ class UDPServer : public RefCounted {
Ref<NetSocket> _sock;
static void _bind_methods();

#ifndef DISABLE_DEPRECATED
Error _listen_bind_compat_120522(uint16_t p_port, const IPAddress &p_bind_address = IPAddress("*"));
static void _bind_compatibility_methods();
#endif // DISABLE_DEPRECATED

public:
void remove_peer(IPAddress p_ip, int p_port);
Error listen(uint16_t p_port, const IPAddress &p_bind_address = IPAddress("*"));
Error listen(int64_t p_port, const IPAddress &p_bind_address = IPAddress("*"));
Error poll();
int get_local_port() const;
bool is_listening() const;
Expand Down
7 changes: 7 additions & 0 deletions misc/extension_api_validation/4.7-stable/GH-120522.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
GH-120522
--------------

Validate extension JSON: Error: Field 'classes/TCPServer/methods/listen/arguments/0': meta changed value in new API, from "uint16" to "int64".
Validate extension JSON: Error: Field 'classes/UDPServer/methods/listen/arguments/0': meta changed value in new API, from "uint16" to "int64".

Changed the "port" parameter type in TCPServer.listen() and UDPServer.listen() from uint16_t to int64_t. Now it checks if it lies in the range 0-65535, and returns an error if not.
Comment on lines +4 to +7

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to provide compat methods, even though the underlying Variant type will be the same, because of ptrcall and call implications.

cc @dsnopek

@NoNormalDev NoNormalDev Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the compat methods based on https://chat.godotengine.org/channel/new-contributors?msg=aT4RZYy2hKmDX6AWd, which fixed the checks failing... Really unsure now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added back the compat methods, and now .NET is complaining...

Loading