1
0
mirror of https://gitlab.com/obbart/universal_robots_ros_driver.git synced 2026-04-12 11:00:47 +02:00

Added set options function for sockets

This commit is contained in:
Simon Rasmussen
2017-05-19 01:22:42 +02:00
parent 8d845c6f38
commit 0c23d0bf3d
5 changed files with 19 additions and 1 deletions

View File

@@ -16,6 +16,12 @@ TCPSocket::~TCPSocket()
close();
}
void TCPSocket::setOptions(int socket_fd)
{
int flag = 1;
setsockopt(socket_fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(int));
}
bool TCPSocket::setup(std::string &host, int port)
{
if(state_ == SocketState::Connected)
@@ -63,6 +69,7 @@ bool TCPSocket::setup(std::string &host, int port)
}
else
{
setOptions(socket_fd_);
state_ = SocketState::Connected;
LOG_INFO("Connection established for %s:%d", host.c_str(), port);
}