mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
added binary API to StreamPeer, fixes #2863
This commit is contained in:
@@ -479,6 +479,13 @@ Error StreamPeerOpenSSL::get_partial_data(uint8_t* p_buffer, int p_bytes,int &r_
|
||||
return OK;
|
||||
}
|
||||
|
||||
int StreamPeerOpenSSL::get_available_bytes() const {
|
||||
|
||||
ERR_FAIL_COND_V(!connected,0);
|
||||
|
||||
return SSL_pending(ssl);
|
||||
|
||||
}
|
||||
StreamPeerOpenSSL::StreamPeerOpenSSL() {
|
||||
|
||||
ctx=NULL;
|
||||
|
||||
@@ -71,6 +71,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;
|
||||
|
||||
static void initialize_ssl();
|
||||
static void finalize_ssl();
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <string.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#ifndef NO_FCNTL
|
||||
#ifdef __HAIKU__
|
||||
#include <fcntl.h>
|
||||
@@ -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;
|
||||
|
||||
@@ -67,6 +67,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;
|
||||
|
||||
Reference in New Issue
Block a user