Skip to content

Commit

Permalink
Set both rcvbuf and sndbuf for accepted and peer clients
Browse files Browse the repository at this point in the history
  • Loading branch information
cYKatherine committed Dec 5, 2024
1 parent c326fdd commit f7dced6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions vsock-bridge/include/listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ namespace vsockio
throw std::runtime_error("error setting SO_RCVBUF");
}

if (setsockopt(clientFd, SOL_SOCKET, SO_SNDBUF, &_sndbuf, sizeof(int)) < 0)
{
close(clientFd);
throw std::runtime_error("error setting SO_SNDBUF");
}

auto outPeer = connectToPeer();
if (!outPeer)
{
Expand Down Expand Up @@ -218,6 +224,12 @@ namespace vsockio
return nullptr;
}

if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &_rcvbuf, sizeof(int)) < 0)
{
close(fd);
throw std::runtime_error("error setting SO_RCVBUF");
}

if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &_sndbuf, sizeof(int)) < 0)
{
close(fd);
Expand Down

0 comments on commit f7dced6

Please sign in to comment.