mirror of
https://github.com/pavel-odintsov/fastnetmon
synced 2024-06-03 11:46:31 +02:00
Added logic to support setsockopt in Netflow plugin on Windows
This commit is contained in:
parent
f2dfbd751b
commit
34af34d053
|
@ -2520,7 +2520,13 @@ void start_netflow_collector(std::string netflow_host, unsigned int netflow_port
|
|||
|
||||
int reuse_port_optval = 1;
|
||||
|
||||
#ifdef _WIN32
|
||||
// Windows uses char* as 4rd argument: https://learn.microsoft.com/en-gb/windows/win32/api/winsock/nf-winsock-getsockopt and we need to add explicit cast
|
||||
// I prefer not to expand this logic to other platforms without testing
|
||||
auto set_reuse_port_res = setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT, (char*)&reuse_port_optval, sizeof(reuse_port_optval))
|
||||
#else
|
||||
auto set_reuse_port_res = setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT, &reuse_port_optval, sizeof(reuse_port_optval));
|
||||
#endif
|
||||
|
||||
if (set_reuse_port_res != 0) {
|
||||
logger << log4cpp::Priority::ERROR << "Cannot enable reuse port mode";
|
||||
|
|
Loading…
Reference in New Issue