diff --git a/vsock-bridge/include/listener.h b/vsock-bridge/include/listener.h index 52383df..c4c39c8 100644 --- a/vsock-bridge/include/listener.h +++ b/vsock-bridge/include/listener.h @@ -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, &_acceptSndBuf, sizeof(int)) < 0) + { + close(clientFd); + throw std::runtime_error("error setting _acceptSndBuf to SO_SNDBUF"); + } + auto outPeer = connectToPeer(); if (!outPeer) { @@ -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)