-------------------------------------------------------------------------*\ * Turns a master unix object into a client object. \*-------------------------------------------------------------------------*/
| 226 | * Turns a master unix object into a client object. |
| 227 | \*-------------------------------------------------------------------------*/ |
| 228 | static 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 | |
| 250 | static int meth_connect(lua_State *L) |
| 251 | { |
no test coverage detected