17# include <ace/INET_Addr.h>
18# include <ace/os_include/netinet/os_tcp.h>
23#elif defined(__unix__) || defined(__APPLE__)
24# include <netinet/tcp.h>
34 if (address.getPort() == -1) {
37 std::string host = address.getHost();
38 yarp::os::impl::TcpConnector connector;
40 if (address.getHost() ==
"localhost") {
47 if (address.hasTimeout()) {
51 int result = connector.connect(stream,
addr, timeout, ACE_Addr::sap_any, 1);
55 if (address.hasTimeout()) {
58 timeout.tv_sec =
static_cast<int>(address.getTimeout());
59 timeout.tv_usec = (address.getTimeout() - timeout.tv_sec) * 1000000;
60 result = connector.connect(stream, address, &timeout);
62 result = connector.connect(stream, address,
nullptr);
71 "TCP connection to tcp:/%s failed to open",
72 address.toURI(
false).c_str());
80 int result =
acceptor.accept(stream);
89void SocketTwoWayStream::updateAddresses()
96 stream.get_local_addr(local);
97 stream.get_remote_addr(remote);
108 memset(&local, 0,
sizeof(local));
109 memset(&remote, 0,
sizeof(remote));
110 stream.get_local_addr(local);
111 stream.get_remote_addr(remote);
115 const char*
ret =
nullptr;
const yarp::os::LogComponent & SOCKETTWOWAYSTREAM()
A mini-server for performing network communication in the background.
static std::string getHostName(bool prefer_loopback=false, const std::string &seed="")
A stream abstraction for socket communication.
int getTypeOfService() override
int open(const Contact &address)
bool setTypeOfService(int tos) override
#define yCError(component,...)
#define yCDebug(component,...)
#define YARP_OS_LOG_COMPONENT(name, name_string)
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.