Skip to content

Commit

Permalink
Make TLM sockets reusable
Browse files Browse the repository at this point in the history
  • Loading branch information
robbr48 committed May 7, 2019
1 parent f270b90 commit ce3b09d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions common/Communication/TLMClientComm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ int TLMClientComm::ConnectManager(string& callname, int portnr) {
TLMErrorLog::Info("TLM manager host found, trying to connect...");
}

bool val = true;
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&val, sizeof(int));

count = 0;

while(connect(s, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
Expand Down
3 changes: 3 additions & 0 deletions common/Communication/TLMManagerComm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ int TLMManagerComm::CreateServerSocket() {
return -1;
}

bool val = true;
setsockopt(theSckt, SOL_SOCKET, SO_REUSEADDR, (char*)&val, sizeof(int));

int bindCount = 0;
int maxIterations = 1000; // BUG: should be calculated from a max. port range!
// Bind the socket, first try the predefined port, then increase port number.
Expand Down

0 comments on commit ce3b09d

Please sign in to comment.