mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Increase socket send buffer size.
PiperOrigin-RevId: 705225169
This commit is contained in:
committed by
Copybara-Service
parent
0d05883b76
commit
eae28d3a45
@@ -29,6 +29,8 @@ namespace {
|
||||
// Recorded the maximum bytes received in one read is 65586 in the test, but add
|
||||
// a little more for const kMaxByteRecieved for safty reason.
|
||||
constexpr int kMaxByteRecieved = 66000;
|
||||
// SO_SNDBUF is set to 4MB.
|
||||
constexpr int kSendBufSize = 4 * 1024 * 1024;
|
||||
} // namespace
|
||||
|
||||
WifiHotspotSocket::WifiHotspotSocket(StreamSocket socket) {
|
||||
@@ -39,6 +41,21 @@ WifiHotspotSocket::WifiHotspotSocket(StreamSocket socket) {
|
||||
|
||||
WifiHotspotSocket::WifiHotspotSocket(SOCKET socket) {
|
||||
stream_soket_winsock_ = socket;
|
||||
int buffer_size = kSendBufSize;
|
||||
int opt_len = sizeof(buffer_size);
|
||||
if (getsockopt(socket, SOL_SOCKET, SO_SNDBUF,
|
||||
reinterpret_cast<char*>(&buffer_size), &opt_len) == 0) {
|
||||
LOG(INFO) << "Socket send buffer size: " << buffer_size;
|
||||
}
|
||||
if (setsockopt(socket, SOL_SOCKET, SO_SNDBUF,
|
||||
reinterpret_cast<char*>(&buffer_size),
|
||||
sizeof(buffer_size)) != 0) {
|
||||
LOG(WARNING) << "Failed to set SO_SNDBUF: " << WSAGetLastError();
|
||||
}
|
||||
if (getsockopt(socket, SOL_SOCKET, SO_SNDBUF,
|
||||
reinterpret_cast<char*>(&buffer_size), &opt_len) == 0) {
|
||||
LOG(INFO) << "Updated send buffer size to: " << buffer_size;
|
||||
}
|
||||
input_stream_ = SocketInputStream(socket);
|
||||
output_stream_ = SocketOutputStream(socket);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,11 @@ namespace windows {
|
||||
|
||||
WifiLanSocket::WifiLanSocket(StreamSocket socket) {
|
||||
stream_soket_ = socket;
|
||||
LOG(INFO) << "Socket send buffer size: "
|
||||
<< socket.Control().OutboundBufferSizeInBytes();
|
||||
socket.Control().OutboundBufferSizeInBytes(4 * 1024 * 1024);
|
||||
LOG(INFO) << "Updated send buffer size to: "
|
||||
<< socket.Control().OutboundBufferSizeInBytes();
|
||||
input_stream_ = SocketInputStream(socket.InputStream());
|
||||
output_stream_ = SocketOutputStream(socket.OutputStream());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user