summaryrefslogtreecommitdiff
path: root/drivers/unix/stream_peer_tcp_posix.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-01-14 11:07:57 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-01-14 11:10:42 -0300
commitdcb95ec1473eff3f455909cd81c3cd50b1e1159b (patch)
tree60343275911d48ebf993041dec92e1eac112b746 /drivers/unix/stream_peer_tcp_posix.cpp
parent93ab45b6b5c4f8e0619e963156c983009d399a9d (diff)
removed duplicated functions in class hierarchy that were bound more than once
added a check to detect this case in the future
Diffstat (limited to 'drivers/unix/stream_peer_tcp_posix.cpp')
-rw-r--r--drivers/unix/stream_peer_tcp_posix.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp
index f2a1417920..b494de6744 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,8 +217,8 @@ Error StreamPeerTCPPosix::write(const uint8_t* p_data,int p_bytes, int &r_sent,
if (errno != EAGAIN) {
perror("shit?");
- disconnect();
- ERR_PRINT("Server disconnected!\n");
+ disconnect_from_host();
+ ERR_PRINT("Server disconnect_from_hosted!\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,8 +274,8 @@ Error StreamPeerTCPPosix::read(uint8_t* p_buffer, int p_bytes,int &r_received, b
if (errno != EAGAIN) {
perror("shit?");
- disconnect();
- ERR_PRINT("Server disconnected!\n");
+ disconnect_from_host();
+ ERR_PRINT("Server disconnect_from_hosted!\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