From 95a469ad28e54fe05c3ae548725e557f91021d79 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 13 Dec 2015 12:53:29 -0300 Subject: added binary API to StreamPeer, fixes #2863 --- drivers/unix/stream_peer_tcp_posix.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers/unix/stream_peer_tcp_posix.cpp') diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp index 5aa3915893..edf5e02971 100644 --- a/drivers/unix/stream_peer_tcp_posix.cpp +++ b/drivers/unix/stream_peer_tcp_posix.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #ifndef NO_FCNTL #ifdef __HAIKU__ #include @@ -367,6 +368,14 @@ Error StreamPeerTCPPosix::get_partial_data(uint8_t* p_buffer, int p_bytes,int &r return read(p_buffer, p_bytes, r_received, false); }; +int StreamPeerTCPPosix::get_available_bytes() const { + + unsigned long len; + int ret = ioctl(sockfd,FIONREAD,&len); + ERR_FAIL_COND_V(ret==-1,0) + return len; + +} IP_Address StreamPeerTCPPosix::get_connected_host() const { return peer_host; -- cgit v1.2.3