summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/io/file_access_network.cpp2
-rw-r--r--core/io/stream_peer_tcp.cpp1
-rw-r--r--core/io/stream_peer_tcp.h2
-rw-r--r--doc/classes/StreamPeerTCP.xml10
-rw-r--r--drivers/unix/stream_peer_tcp_posix.cpp2
-rw-r--r--drivers/unix/stream_peer_tcp_posix.h2
-rw-r--r--drivers/windows/stream_peer_tcp_winsock.cpp2
-rw-r--r--drivers/windows/stream_peer_tcp_winsock.h2
-rw-r--r--editor/fileserver/editor_file_server.cpp2
9 files changed, 18 insertions, 7 deletions
diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp
index 7b2bccdfec..ef886cdb3c 100644
--- a/core/io/file_access_network.cpp
+++ b/core/io/file_access_network.cpp
@@ -83,7 +83,7 @@ int64_t FileAccessNetworkClient::get_64() {
void FileAccessNetworkClient::_thread_func() {
- client->set_nodelay(true);
+ client->set_no_delay(true);
while (!quit) {
DEBUG_PRINT("SEM WAIT - " + itos(sem->get()));
diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp
index 9cfa810034..5d008904ff 100644
--- a/core/io/stream_peer_tcp.cpp
+++ b/core/io/stream_peer_tcp.cpp
@@ -55,6 +55,7 @@ void StreamPeerTCP::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_connected_host"), &StreamPeerTCP::get_connected_host);
ClassDB::bind_method(D_METHOD("get_connected_port"), &StreamPeerTCP::get_connected_port);
ClassDB::bind_method(D_METHOD("disconnect_from_host"), &StreamPeerTCP::disconnect_from_host);
+ ClassDB::bind_method(D_METHOD("set_no_delay", "enabled"), &StreamPeerTCP::set_no_delay);
BIND_ENUM_CONSTANT(STATUS_NONE);
BIND_ENUM_CONSTANT(STATUS_CONNECTING);
diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h
index fc84525c5f..8a16d820f2 100644
--- a/core/io/stream_peer_tcp.h
+++ b/core/io/stream_peer_tcp.h
@@ -65,7 +65,7 @@ public:
virtual void disconnect_from_host() = 0;
virtual IP_Address get_connected_host() const = 0;
virtual uint16_t get_connected_port() const = 0;
- virtual void set_nodelay(bool p_enabled) = 0;
+ virtual void set_no_delay(bool p_enabled) = 0;
static Ref<StreamPeerTCP> create_ref();
static StreamPeerTCP *create();
diff --git a/doc/classes/StreamPeerTCP.xml b/doc/classes/StreamPeerTCP.xml
index 37fec62cbc..73e9b97367 100644
--- a/doc/classes/StreamPeerTCP.xml
+++ b/doc/classes/StreamPeerTCP.xml
@@ -29,6 +29,16 @@
Disconnect from host.
</description>
</method>
+ <method name="set_no_delay">
+ <return type="void">
+ </return>
+ <argument index="0" name="enabled" type="bool">
+ </argument>
+ <description>
+ Disable Nagle algorithm to improve latency for small packets.
+ Note that for applications that send large packets, or need to transfer a lot of data, this can reduce total bandwidth.
+ </description>
+ </method>
<method name="get_connected_host" qualifiers="const">
<return type="String">
</return>
diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp
index ba9481d36b..17112e5ab5 100644
--- a/drivers/unix/stream_peer_tcp_posix.cpp
+++ b/drivers/unix/stream_peer_tcp_posix.cpp
@@ -304,7 +304,7 @@ Error StreamPeerTCPPosix::read(uint8_t *p_buffer, int p_bytes, int &r_received,
return OK;
};
-void StreamPeerTCPPosix::set_nodelay(bool p_enabled) {
+void StreamPeerTCPPosix::set_no_delay(bool p_enabled) {
ERR_FAIL_COND(!is_connected_to_host());
int flag = p_enabled ? 1 : 0;
diff --git a/drivers/unix/stream_peer_tcp_posix.h b/drivers/unix/stream_peer_tcp_posix.h
index 5770ae48f4..bcebe57771 100644
--- a/drivers/unix/stream_peer_tcp_posix.h
+++ b/drivers/unix/stream_peer_tcp_posix.h
@@ -77,7 +77,7 @@ public:
virtual Status get_status() const;
virtual void disconnect_from_host();
- virtual void set_nodelay(bool p_enabled);
+ virtual void set_no_delay(bool p_enabled);
static void make_default();
diff --git a/drivers/windows/stream_peer_tcp_winsock.cpp b/drivers/windows/stream_peer_tcp_winsock.cpp
index d6a320fb5e..55775fc231 100644
--- a/drivers/windows/stream_peer_tcp_winsock.cpp
+++ b/drivers/windows/stream_peer_tcp_winsock.cpp
@@ -332,7 +332,7 @@ Error StreamPeerTCPWinsock::connect_to_host(const IP_Address &p_host, uint16_t p
return OK;
};
-void StreamPeerTCPWinsock::set_nodelay(bool p_enabled) {
+void StreamPeerTCPWinsock::set_no_delay(bool p_enabled) {
ERR_FAIL_COND(!is_connected_to_host());
int flag = p_enabled ? 1 : 0;
setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int));
diff --git a/drivers/windows/stream_peer_tcp_winsock.h b/drivers/windows/stream_peer_tcp_winsock.h
index 9be8414878..a0177d374e 100644
--- a/drivers/windows/stream_peer_tcp_winsock.h
+++ b/drivers/windows/stream_peer_tcp_winsock.h
@@ -81,7 +81,7 @@ public:
static void make_default();
static void cleanup();
- virtual void set_nodelay(bool p_enabled);
+ virtual void set_no_delay(bool p_enabled);
StreamPeerTCPWinsock();
~StreamPeerTCPWinsock();
diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp
index 56fb7633e7..a218070933 100644
--- a/editor/fileserver/editor_file_server.cpp
+++ b/editor/fileserver/editor_file_server.cpp
@@ -55,7 +55,7 @@ void EditorFileServer::_subthread_start(void *s) {
ClientData *cd = (ClientData *)s;
- cd->connection->set_nodelay(true);
+ cd->connection->set_no_delay(true);
uint8_t buf4[8];
Error err = cd->connection->get_data(buf4, 4);
if (err != OK) {