Skip to content

Commit

Permalink
Fix bind failure when fujinet-pc is trying to connect first
Browse files Browse the repository at this point in the history
  • Loading branch information
markjfisher committed Jan 18, 2024
1 parent 627fee2 commit 61fd306
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions source/SPoverSLIP/Listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ void Listener::listener_function()
address.sin_port = htons(port_);
address.sin_addr.s_addr = inet_addr(ip_address_.c_str());

int opt = 1;
if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1) {
LogFileOutput("Listener::listener_function - setsockopt failed\n");
return;
}

if (bind(server_fd, (struct sockaddr *)&address, sizeof(address)) == SOCKET_ERROR)
{
LogFileOutput("Listener::listener_function - bind failed\n");
Expand Down

0 comments on commit 61fd306

Please sign in to comment.