diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2020-03-06 12:57:28 +0100 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2020-03-08 12:16:09 +0100 |
commit | 74051c77dc3ec1548f8efedfd892a0b2ad3537ad (patch) | |
tree | 336b530a48ca3930eb42a83a866937f9bcba0e1e | |
parent | 8cb6d5daa4e41443d658265379b6079d8a087b41 (diff) |
Add TCP poll function (not exposed).
Used to know if we can read or write without blocking.
-rw-r--r-- | core/io/stream_peer_tcp.cpp | 5 | ||||
-rw-r--r-- | core/io/stream_peer_tcp.h | 3 |
2 files changed, 8 insertions, 0 deletions
diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp index 044431743a..f0c5816d73 100644 --- a/core/io/stream_peer_tcp.cpp +++ b/core/io/stream_peer_tcp.cpp @@ -288,6 +288,11 @@ void StreamPeerTCP::disconnect_from_host() { peer_port = 0; } +Error StreamPeerTCP::poll(NetSocket::PollType p_type, int timeout) { + ERR_FAIL_COND_V(_sock.is_null() || !_sock->is_open(), ERR_UNAVAILABLE); + return _sock->poll(p_type, timeout); +} + Error StreamPeerTCP::put_data(const uint8_t *p_data, int p_bytes) { int total; diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h index f16d4a2bd4..327aa3cc3b 100644 --- a/core/io/stream_peer_tcp.h +++ b/core/io/stream_peer_tcp.h @@ -78,6 +78,9 @@ public: void set_no_delay(bool p_enabled); + // Poll functions (wait or check for writable, readable) + Error poll(NetSocket::PollType p_type, int timeout = 0); + // Read/Write from StreamPeer Error put_data(const uint8_t *p_data, int p_bytes); Error put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent); |