summaryrefslogtreecommitdiff
path: root/drivers/unix/stream_peer_tcp_posix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/unix/stream_peer_tcp_posix.cpp')
-rw-r--r--drivers/unix/stream_peer_tcp_posix.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp
index f2a1417920..82f3115f4b 100644
--- a/drivers/unix/stream_peer_tcp_posix.cpp
+++ b/drivers/unix/stream_peer_tcp_posix.cpp
@@ -139,14 +139,14 @@ void StreamPeerTCPPosix::set_socket(int p_sockfd, IP_Address p_host, int p_port,
peer_port = p_port;
};
-Error StreamPeerTCPPosix::connect(const IP_Address& p_host, uint16_t p_port) {
+Error StreamPeerTCPPosix::connect_to_host(const IP_Address& p_host, uint16_t p_port) {
ERR_FAIL_COND_V( p_host == IP_Address(), ERR_INVALID_PARAMETER);
sockfd = _socket_create(ip_type, SOCK_STREAM, IPPROTO_TCP);
if (sockfd == -1) {
ERR_PRINT("Socket creation failed!");
- disconnect();
+ disconnect_from_host();
//perror("socket");
return FAILED;
};
@@ -165,7 +165,7 @@ Error StreamPeerTCPPosix::connect(const IP_Address& p_host, uint16_t p_port) {
if (::connect(sockfd, (struct sockaddr *)&their_addr,addr_size) == -1 && errno != EINPROGRESS) {
ERR_PRINT("Connection to remote host failed!");
- disconnect();
+ disconnect_from_host();
return FAILED;
};
@@ -217,7 +217,7 @@ Error StreamPeerTCPPosix::write(const uint8_t* p_data,int p_bytes, int &r_sent,
if (errno != EAGAIN) {
perror("shit?");
- disconnect();
+ disconnect_from_host();
ERR_PRINT("Server disconnected!\n");
return FAILED;
};
@@ -243,7 +243,7 @@ Error StreamPeerTCPPosix::write(const uint8_t* p_data,int p_bytes, int &r_sent,
Error StreamPeerTCPPosix::read(uint8_t* p_buffer, int p_bytes,int &r_received, bool p_block) {
- if (!is_connected()) {
+ if (!is_connected_to_host()) {
return FAILED;
};
@@ -274,7 +274,7 @@ Error StreamPeerTCPPosix::read(uint8_t* p_buffer, int p_bytes,int &r_received, b
if (errno != EAGAIN) {
perror("shit?");
- disconnect();
+ disconnect_from_host();
ERR_PRINT("Server disconnected!\n");
return FAILED;
};
@@ -308,12 +308,12 @@ Error StreamPeerTCPPosix::read(uint8_t* p_buffer, int p_bytes,int &r_received, b
void StreamPeerTCPPosix::set_nodelay(bool p_enabled) {
- ERR_FAIL_COND(!is_connected());
+ ERR_FAIL_COND(!is_connected_to_host());
int flag=p_enabled?1:0;
setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(int));
}
-bool StreamPeerTCPPosix::is_connected() const {
+bool StreamPeerTCPPosix::is_connected_to_host() const {
if (status == STATUS_NONE || status == STATUS_ERROR) {
@@ -336,7 +336,7 @@ StreamPeerTCP::Status StreamPeerTCPPosix::get_status() const {
};
-void StreamPeerTCPPosix::disconnect() {
+void StreamPeerTCPPosix::disconnect_from_host() {
if (sockfd != -1)
close(sockfd);
@@ -398,7 +398,7 @@ StreamPeerTCPPosix::StreamPeerTCPPosix() {
StreamPeerTCPPosix::~StreamPeerTCPPosix() {
- disconnect();
+ disconnect_from_host();
};
#endif