MCPcopy Create free account
hub / github.com/apache/thrift / l_socket_accept

Function l_socket_accept

lib/lua/src/luasocket.c:306–321  ·  view source on GitHub ↗

accept()

Source from the content-addressed store, hash-verified

304
305// accept()
306static int l_socket_accept(lua_State *L) {
307 const char *err;
308 p_tcp self = (p_tcp) checktype(L, 1, SOCKET_SERVER);
309 t_socket sock;
310 err = tcp_accept(&self->sock, &sock, self->timeout);
311 if (!err) { // Success
312 // Create a reference to the client
313 p_tcp client = (p_tcp) lua_newuserdata(L, sizeof(t_tcp));
314 settype(L, 2, SOCKET_CLIENT);
315 socket_setnonblocking(&sock);
316 client->sock = sock;
317 client->timeout = self->timeout;
318 return 1;
319 }
320 LUA_CHECK_RETURN(L, err);
321}
322
323static int l_socket_listen(lua_State *L) {
324 const char* err;

Callers

nothing calls this directly

Calls 4

checktypeFunction · 0.85
tcp_acceptFunction · 0.85
settypeFunction · 0.85
socket_setnonblockingFunction · 0.85

Tested by

no test coverage detected