MCPcopy Create free account
hub / github.com/acl-dev/acl / accept

Method accept

lib_acl_cpp/src/stream/server_socket.cpp:159–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159socket_stream* server_socket::accept(int timeout /* = 0 */,
160 bool* etimed /* = NULL */)
161{
162 if (etimed) {
163 *etimed = false;
164 }
165
166 if (fd_ == ACL_SOCKET_INVALID) {
167 logger_error("server socket not opened!");
168 return NULL;
169 }
170
171 // if ((open_flag_ & ACL_NON_BLOCKING) && timeout > 0)
172 if (timeout > 0) {
173 if (acl_read_wait(fd_, timeout) == -1) {
174 if (etimed) {
175 *etimed = true;
176 }
177 return NULL;
178 }
179 }
180
181 ACL_SOCKET fd = acl_accept(fd_, NULL, 0, NULL);
182 if (fd == ACL_SOCKET_INVALID) {
183 if (open_flag_ & ACL_NON_BLOCKING) {
184 logger_error("accept error %s", last_serror());
185 } else if (last_error() != ACL_EAGAIN
186 && last_error() != ACL_EWOULDBLOCK) {
187
188 logger_error("accept error %s", last_serror());
189 }
190 return NULL;
191 }
192
193 socket_stream* client = NEW socket_stream();
194 if (client->open(fd) == false) {
195 logger_error("create socket_stream error!");
196 return NULL;
197 }
198
199 if (!unix_sock_) {
200 acl_tcp_set_nodelay(fd);
201 }
202
203 return client;
204}
205
206void server_socket::set_tcp_defer_accept(int timeout)
207{

Callers 15

handle_acceptMethod · 0.45
mainFunction · 0.45
start_threadsFunction · 0.45
listen_fiberFunction · 0.45
server_pool2_runFunction · 0.45
listen_callbackMethod · 0.45
runMethod · 0.45
wait_connectFunction · 0.45
fiber_acceptFunction · 0.45
fiber_acceptFunction · 0.45
fiber_serverFunction · 0.45
fiber_acceptFunction · 0.45

Calls 7

acl_read_waitFunction · 0.85
acl_acceptFunction · 0.85
last_errorFunction · 0.85
acl_tcp_set_nodelayFunction · 0.85
last_serrorFunction · 0.50
socket_streamClass · 0.50
openMethod · 0.45

Tested by 1

runMethod · 0.36