MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / setOptions

Method setOptions

3rdparty/cppdap/src/socket.cpp:131–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129 }
130
131 void setOptions() {
132 RLock l(mutex);
133 if (s == InvalidSocket) {
134 return;
135 }
136
137 int enable = 1;
138
139#if !defined(_WIN32)
140 // Prevent sockets lingering after process termination, causing
141 // reconnection issues on the same port.
142 setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&enable, sizeof(enable));
143
144 struct {
145 int l_onoff; /* linger active */
146 int l_linger; /* how many seconds to linger for */
147 } linger = {false, 0};
148 setsockopt(s, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(linger));
149#endif // !defined(_WIN32)
150
151 // Enable TCP_NODELAY.
152 // DAP usually consists of small packet requests, with small packet
153 // responses. When there are many frequent, blocking requests made,
154 // Nagle's algorithm can dramatically limit the request->response rates.
155 setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char*)&enable, sizeof(enable));
156 }
157
158 // dap::ReaderWriter compliance
159 bool isOpen() {

Callers 2

createMethod · 0.45
acceptMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected