MCPcopy Create free account
hub / github.com/defold/defold / unix_tryconnect

Function unix_tryconnect

engine/script/src/luasocket/unix.c:228–248  ·  view source on GitHub ↗

-------------------------------------------------------------------------*\ * Turns a master unix object into a client object. \*-------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

226* Turns a master unix object into a client object.
227\*-------------------------------------------------------------------------*/
228static const char *unix_tryconnect(p_unix un, const char *path)
229{
230 struct sockaddr_un remote;
231 int err;
232 size_t len = strlen(path);
233 if (len >= sizeof(remote.sun_path)) return "path too long";
234 memset(&remote, 0, sizeof(remote));
235 strcpy(remote.sun_path, path);
236 remote.sun_family = AF_UNIX;
237 timeout_markstart(&un->tm);
238#ifdef UNIX_HAS_SUN_LEN
239 remote.sun_len = sizeof(remote.sun_family) + sizeof(remote.sun_len)
240 + len + 1;
241 err = socket_connect(&un->sock, (SA *) &remote, remote.sun_len, &un->tm);
242#else
243 err = socket_connect(&un->sock, (SA *) &remote,
244 sizeof(remote.sun_family) + len, &un->tm);
245#endif
246 if (err != IO_DONE) socket_destroy(&un->sock);
247 return socket_strerror(err);
248}
249
250static int meth_connect(lua_State *L)
251{

Callers 1

meth_connectFunction · 0.85

Calls 4

timeout_markstartFunction · 0.85
socket_connectFunction · 0.70
socket_destroyFunction · 0.70
socket_strerrorFunction · 0.70

Tested by

no test coverage detected