Skip to content

Commit

Permalink
Add reuse socket to TCP agent (#301)
Browse files Browse the repository at this point in the history
* Add reuse socket to tpc agent

* Fix typo
  • Loading branch information
Acuadros95 authored Jan 20, 2022
1 parent f47b29e commit 2abb84d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/cpp/transport/tcp/TCPv4AgentLinux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ bool TCPv4Agent::init()

if (-1 != listener_poll_.fd)
{
int value = 1;
if (0 != setsockopt(listener_poll_.fd, SOL_SOCKET, SO_REUSEADDR, &value, sizeof(value)))
{
UXR_AGENT_LOG_ERROR(
UXR_DECORATE_YELLOW("SO_REUSEADDR socket option failed"),
"port: {}, errno: {}",
agent_port_, errno);
}

struct sockaddr_in address;

address.sin_family = AF_INET;
Expand Down

0 comments on commit 2abb84d

Please sign in to comment.