Skip to content
This repository has been archived by the owner on Apr 6, 2019. It is now read-only.

Commit

Permalink
[2.4.5] retrieve the IP address of the incoming connection and store …
Browse files Browse the repository at this point in the history
…it in the socket information when accepting a connection
  • Loading branch information
Simon Ninon committed Jul 5, 2017
1 parent 290dc38 commit 6f6cb21
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions sources/network/unix/tcp_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <cstring>

#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
Expand Down Expand Up @@ -212,8 +213,7 @@ tcp_socket::accept(void) {

if (client_fd == __TACOPIE_INVALID_FD) { __TACOPIE_THROW(error, "accept() failure"); }

//! TODO: init with real client addr
return {client_fd, "", client_info.sin_port, type::CLIENT};
return {client_fd, inet_ntoa(client_info.sin_addr), client_info.sin_port, type::CLIENT};
}

//!
Expand Down Expand Up @@ -314,4 +314,4 @@ tcp_socket::operator!=(const tcp_socket& rhs) const {
return !operator==(rhs);
}

} //! tacopie
} // namespace tacopie
5 changes: 2 additions & 3 deletions sources/network/windows/tcp_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ tcp_socket::accept(void) {

if (client_fd == __TACOPIE_INVALID_FD) { __TACOPIE_THROW(error, "accept() failure"); }

//! TODO: init with real client addr
return {client_fd, "", client_info.sin_port, type::CLIENT};
return {client_fd, inet_ntoa(client_info.sin_addr), client_info.sin_port, type::CLIENT};
}

//!
Expand Down Expand Up @@ -274,4 +273,4 @@ tcp_socket::operator!=(const tcp_socket& rhs) const {
return !operator==(rhs);
}

} //! tacopie
} // namespace tacopie

0 comments on commit 6f6cb21

Please sign in to comment.