unix(p1, p2 = v2)
public
returns an addrinfo object for UNIX socket address.
socktype specifies the
socket type. If it is omitted, :STREAM is used.
Addrinfo.unix("/tmp/sock")
Addrinfo.unix("/tmp/sock", :DGRAM)
static VALUE
addrinfo_s_unix(int argc, VALUE *argv, VALUE self)
{
VALUE path, vsocktype, addr;
int socktype;
rb_addrinfo_t *rai;
rb_scan_args(argc, argv, "11", &path, &vsocktype);
if (NIL_P(vsocktype))
socktype = SOCK_STREAM;
else
socktype = rsock_socktype_arg(vsocktype);
addr = addrinfo_s_allocate(rb_cAddrinfo);
DATA_PTR(addr) = rai = alloc_addrinfo();
init_unix_addrinfo(rai, path, socktype);
OBJ_INFECT(addr, path);
return addr;
}