Skip to content

Instantly share code, notes, and snippets.

@shugo
Created January 30, 2013 09:40
Show Gist options
  • Save shugo/4671992 to your computer and use it in GitHub Desktop.
Save shugo/4671992 to your computer and use it in GitHub Desktop.
rsock_unix_sockaddr_len
socklen_t
rsock_unix_sockaddr_len(VALUE path)
{
#ifdef __linux__
if (RSTRING_PTR(path)[0] == '\0') {
/* abstract namespace; see unix(7) for details. */
return (socklen_t) offsetof(struct sockaddr_un, sun_path) +
RSTRING_LEN(path);
}
else {
#endif
return (socklen_t) sizeof(struct sockaddr_un);
#ifdef __linux__
}
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment