CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
multigpu
keepAlive.h
Go to the documentation of this file.
1
// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma de Barcelona (UAB).
2
// This work is licensed under the terms of the MIT license.
3
// For a copy, see <https://opensource.org/licenses/MIT>.
4
5
#pragma once
6
7
#include <boost/asio/ip/tcp.hpp>
8
9
#if defined(__linux__)
10
#include <netinet/in.h>
11
#include <netinet/tcp.h>
12
#include <sys/socket.h>
13
#endif
14
15
namespace
carla
{
16
namespace
multigpu
{
17
18
/// Lets either end notice a peer that vanished without closing the
19
/// connection (a killed host, a cut link): on Linux, after 10 s of silence
20
/// three probes 5 s apart, so about 25 s.
21
inline
void
EnableKeepAlive
(boost::asio::ip::tcp::socket &socket) {
22
boost::system::error_code ec;
23
socket.set_option(boost::asio::socket_base::keep_alive(
true
), ec);
24
#if defined(__linux__)
25
const
int
idle_seconds = 10;
26
const
int
interval_seconds = 5;
27
const
int
probes = 3;
28
const
auto
handle = socket.native_handle();
29
::setsockopt(handle, IPPROTO_TCP, TCP_KEEPIDLE, &idle_seconds,
sizeof
(idle_seconds));
30
::setsockopt(handle, IPPROTO_TCP, TCP_KEEPINTVL, &interval_seconds,
sizeof
(interval_seconds));
31
::setsockopt(handle, IPPROTO_TCP, TCP_KEEPCNT, &probes,
sizeof
(probes));
32
#endif
33
}
34
35
}
// namespace multigpu
36
}
// namespace carla
carla::multigpu
Definition
commands.h:17
carla::multigpu::EnableKeepAlive
void EnableKeepAlive(boost::asio::ip::tcp::socket &socket)
Lets either end notice a peer that vanished without closing the connection (a killed host,...
Definition
keepAlive.h:21
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
Generated by
1.18.0