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 --- platform/windows/stream_peer_winsock.cpp | 8 ++++++++ platform/windows/stream_peer_winsock.h | 2 ++ 2 files changed, 10 insertions(+) (limited to 'platform/windows') diff --git a/platform/windows/stream_peer_winsock.cpp b/platform/windows/stream_peer_winsock.cpp index e8245c92e5..5bc3e34107 100644 --- a/platform/windows/stream_peer_winsock.cpp +++ b/platform/windows/stream_peer_winsock.cpp @@ -342,6 +342,14 @@ void StreamPeerWinsock::set_nodelay(bool p_enabled) { setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(int)); } +int StreamPeerWinsock::get_available_bytes() const { + + unsigned long len; + int ret = ioctlsocket(sockfd,FIONREAD,&len); + ERR_FAIL_COND_V(ret==-1,0) + return len; + +} IP_Address StreamPeerWinsock::get_connected_host() const { diff --git a/platform/windows/stream_peer_winsock.h b/platform/windows/stream_peer_winsock.h index 373b502d2c..5dd836aa0c 100644 --- a/platform/windows/stream_peer_winsock.h +++ b/platform/windows/stream_peer_winsock.h @@ -66,6 +66,8 @@ public: virtual Error get_data(uint8_t* p_buffer, int p_bytes); virtual Error get_partial_data(uint8_t* p_buffer, int p_bytes,int &r_received); + virtual int get_available_bytes() const; + void set_socket(int p_sockfd, IP_Address p_host, int p_port); virtual IP_Address get_connected_host() const; -- cgit v1.2.3