MCPcopy Create free account
hub / github.com/Tencent/UnLua / global_create

Function global_create

Plugins/UnLuaExtensions/LuaSocket/Source/src/unixstream.cpp:334–356  ·  view source on GitHub ↗

=========================================================================*\ * Library functions \*=========================================================================*/ -------------------------------------------------------------------------*\ * Creates a master unixstream object \*-------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

332* Creates a master unixstream object
333\*-------------------------------------------------------------------------*/
334static int global_create(lua_State *L) {
335 t_socket sock;
336 int err = socket_create(&sock, AF_UNIX, SOCK_STREAM, 0);
337 /* try to allocate a system socket */
338 if (err == IO_DONE) {
339 /* allocate unixstream object */
340 p_unix un = (p_unix) lua_newuserdata(L, sizeof(t_unix));
341 /* set its type as master object */
342 auxiliar_setclass(L, "unixstream{master}", -1);
343 /* initialize remaining structure fields */
344 socket_setnonblocking(&sock);
345 un->sock = sock;
346 io_init(&un->io, (p_send) socket_send, (p_recv) socket_recv,
347 (p_error) socket_ioerror, &un->sock);
348 timeout_init(&un->tm, -1, -1);
349 buffer_init(&un->buf, &un->io, &un->tm);
350 return 1;
351 } else {
352 lua_pushnil(L);
353 lua_pushstring(L, socket_strerror(err));
354 return 2;
355 }
356}
357
358#endif

Callers

nothing calls this directly

Calls 9

auxiliar_setclassFunction · 0.85
io_initFunction · 0.85
timeout_initFunction · 0.85
buffer_initFunction · 0.85
lua_pushnilFunction · 0.85
lua_pushstringFunction · 0.85
socket_createFunction · 0.70
socket_setnonblockingFunction · 0.70
socket_strerrorFunction · 0.70

Tested by

no test coverage detected