Skip to content

Commit

Permalink
Add rcv and snd buf to both peer and accept
Browse files Browse the repository at this point in the history
  • Loading branch information
cYKatherine committed Dec 5, 2024
1 parent fc76309 commit ad55079
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions vsock-bridge/include/listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ namespace vsockio
return;
}

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

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

auto outPeer = connectToPeer();
if (!outPeer)
{
Expand Down Expand Up @@ -209,6 +221,18 @@ namespace vsockio
return nullptr;
}

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

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

auto addrAndLen = _connectEp->getAddress();
int status = connect(fd, addrAndLen.first, addrAndLen.second);
if (status == 0)
Expand Down

0 comments on commit ad55079

Please sign in to comment.