summaryrefslogtreecommitdiffstats
path: root/modules/websocket/wsl_peer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/websocket/wsl_peer.cpp')
-rw-r--r--modules/websocket/wsl_peer.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/modules/websocket/wsl_peer.cpp b/modules/websocket/wsl_peer.cpp
index 38cb614847..0a9a4053e3 100644
--- a/modules/websocket/wsl_peer.cpp
+++ b/modules/websocket/wsl_peer.cpp
@@ -99,6 +99,7 @@ void WSLPeer::Resolver::try_next_candidate(Ref<StreamPeerTCP> &p_tcp) {
p_tcp->poll();
StreamPeerTCP::Status status = p_tcp->get_status();
if (status == StreamPeerTCP::STATUS_CONNECTED) {
+ // On Windows, setting TCP_NODELAY may fail if the socket is still connecting.
p_tcp->set_no_delay(true);
ip_candidates.clear();
return;
@@ -124,8 +125,8 @@ void WSLPeer::Resolver::try_next_candidate(Ref<StreamPeerTCP> &p_tcp) {
/// Server functions
///
Error WSLPeer::accept_stream(Ref<StreamPeer> p_stream) {
- ERR_FAIL_COND_V(wsl_ctx || tcp.is_valid(), ERR_ALREADY_IN_USE);
ERR_FAIL_COND_V(p_stream.is_null(), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(ready_state != STATE_CLOSED && ready_state != STATE_CLOSING, ERR_ALREADY_IN_USE);
_clear();
@@ -142,6 +143,7 @@ Error WSLPeer::accept_stream(Ref<StreamPeer> p_stream) {
}
ERR_FAIL_COND_V(connection.is_null() || tcp.is_null(), ERR_INVALID_PARAMETER);
is_server = true;
+ tcp->set_no_delay(true);
ready_state = STATE_CONNECTING;
handshake_buffer->resize(WSL_MAX_HEADER_SIZE);
handshake_buffer->seek(0);
@@ -310,7 +312,7 @@ void WSLPeer::_do_client_handshake() {
ERR_FAIL_COND(tcp.is_null());
// Try to connect to candidates.
- if (resolver.has_more_candidates()) {
+ if (resolver.has_more_candidates() || tcp->get_status() == StreamPeerTCP::STATUS_CONNECTING) {
resolver.try_next_candidate(tcp);
if (resolver.has_more_candidates()) {
return; // Still pending.
@@ -471,9 +473,9 @@ bool WSLPeer::_verify_server_response() {
}
Error WSLPeer::connect_to_url(const String &p_url, Ref<TLSOptions> p_options) {
- ERR_FAIL_COND_V(wsl_ctx || tcp.is_valid(), ERR_ALREADY_IN_USE);
ERR_FAIL_COND_V(p_url.is_empty(), ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(p_options.is_valid() && p_options->is_server(), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(ready_state != STATE_CLOSED && ready_state != STATE_CLOSING, ERR_ALREADY_IN_USE);
_clear();