Skip to content

Commit

Permalink
Don't try to set unknown socket options (#1172)
Browse files Browse the repository at this point in the history
* Don't try to set unknown socket options

These are not avaible on FreeBSD, for example

* individualize ifdefs

* fix whitespace
  • Loading branch information
jspricke authored and dirk-thomas committed Oct 26, 2017
1 parent 266f8a7 commit 6e906e4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion clients/roscpp/src/libros/transport/transport_tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,23 @@ void TransportTCP::setKeepAlive(bool use, uint32_t idle, uint32_t interval, uint
}

/* cygwin SOL_TCP does not seem to support TCP_KEEPIDLE, TCP_KEEPINTVL, TCP_KEEPCNT */
#if defined(SOL_TCP) && !defined(__CYGWIN__)
#if defined(SOL_TCP) && defined(TCP_KEEPIDLE)
val = idle;
if (setsockopt(sock_, SOL_TCP, TCP_KEEPIDLE, &val, sizeof(val)) != 0)
{
ROS_DEBUG("setsockopt failed to set TCP_KEEPIDLE on socket [%d] [%s]", sock_, cached_remote_host_.c_str());
}
#endif

#if defined(SOL_TCP) && defined(TCP_KEEPINTVL)
val = interval;
if (setsockopt(sock_, SOL_TCP, TCP_KEEPINTVL, &val, sizeof(val)) != 0)
{
ROS_DEBUG("setsockopt failed to set TCP_KEEPINTVL on socket [%d] [%s]", sock_, cached_remote_host_.c_str());
}
#endif

#if defined(SOL_TCP) && defined(TCP_KEEPCNT)
val = count;
if (setsockopt(sock_, SOL_TCP, TCP_KEEPCNT, &val, sizeof(val)) != 0)
{
Expand Down

0 comments on commit 6e906e4

Please sign in to comment.