mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
make Nagle's algorithm configurable
This commit is contained in:
parent
e3da256c5d
commit
b6ca7cf918
5 changed files with 50 additions and 0 deletions
|
|
@ -329,6 +329,22 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void setNoDelay(bool noDelay) override {
|
||||
int opt = noDelay ? 1 : 0;
|
||||
if (setsockopt(descriptor, IPPROTO_TCP, TCP_NODELAY, (char*)&opt, sizeof(opt)) < 0) {
|
||||
throw handle_socket_error("setsockopt(TCP_NODELAY) failed");
|
||||
}
|
||||
}
|
||||
|
||||
bool getNoDelay() const override {
|
||||
int opt = 0;
|
||||
socklen_t len = sizeof(opt);
|
||||
if (getsockopt(descriptor, IPPROTO_TCP, TCP_NODELAY, (char*)&opt, &len) < 0) {
|
||||
throw handle_socket_error("getsockopt(TCP_NODELAY) failed");
|
||||
}
|
||||
return opt != 0;
|
||||
}
|
||||
|
||||
void startListen() {
|
||||
while (state == ConnectionState::CONNECTED) {
|
||||
int size = recvsocket(descriptor, buffer.data(), buffer.size());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue