15 #include <sys/socket.h>
31 TcpStream::TcpStream() =
default;
33 TcpStream::~TcpStream() =
default;
37 set_handle(socket(AF_INET, SOCK_STREAM, 0));
38 if (get_handle() == -1) {
39 yCError(TCPSTREAM_POSIX,
"At TcpStream::open there was an error: %d, %s", errno, strerror(errno));
45 int TcpStream::get_local_addr(sockaddr & sa)
48 if (::getsockname(get_handle(), &sa,
reinterpret_cast<socklen_t*
>(&len)) == -1) {
54 int TcpStream::get_remote_addr (sockaddr & sa)
57 if (::getpeername(get_handle(), &sa,
reinterpret_cast<socklen_t*
>(&len)) == -1) {