Add TCP poll function (not exposed).

Used to know if we can read or write without blocking.
This commit is contained in:
Fabio Alessandrelli 2020-03-06 12:57:28 +01:00
parent 8cb6d5daa4
commit 74051c77dc
2 changed files with 8 additions and 0 deletions

View file

@ -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;

View file

@ -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);