method
marshal_dump
v2_6_3 -
Show latest stable
-
0 notes -
Class: Addrinfo
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180 (0)
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (0)
- 2_2_9 (0)
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
marshal_dump()
public
Hide source
static VALUE addrinfo_mdump(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); VALUE sockaddr, afamily, pfamily, socktype, protocol, canonname, inspectname; int afamily_int = ai_get_afamily(rai); ID id; id = rsock_intern_protocol_family(rai->pfamily); if (id == 0) rb_raise(rb_eSocket, "unknown protocol family: %d", rai->pfamily); pfamily = rb_id2str(id); if (rai->socktype == 0) socktype = INT2FIX(0); else { id = rsock_intern_socktype(rai->socktype); if (id == 0) rb_raise(rb_eSocket, "unknown socktype: %d", rai->socktype); socktype = rb_id2str(id); } if (rai->protocol == 0) protocol = INT2FIX(0); else if (IS_IP_FAMILY(afamily_int)) { id = rsock_intern_ipproto(rai->protocol); if (id == 0) rb_raise(rb_eSocket, "unknown IP protocol: %d", rai->protocol); protocol = rb_id2str(id); } else { rb_raise(rb_eSocket, "unknown protocol: %d", rai->protocol); } canonname = rai->canonname; inspectname = rai->inspectname; id = rsock_intern_family(afamily_int); if (id == 0) rb_raise(rb_eSocket, "unknown address family: %d", afamily_int); afamily = rb_id2str(id); switch(afamily_int) { #ifdef HAVE_SYS_UN_H case AF_UNIX: { struct sockaddr_un *su = &rai->addr.un; char *s, *e; s = su->sun_path; e = (char*)su + rai->sockaddr_len; while (s < e && *(e-1) == '\0') e--; sockaddr = rb_str_new(s, e-s); break; } #endif default: { char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV]; int error; error = getnameinfo(&rai->addr.addr, rai->sockaddr_len, hbuf, (socklen_t)sizeof(hbuf), pbuf, (socklen_t)sizeof(pbuf), NI_NUMERICHOST|NI_NUMERICSERV); if (error) { rsock_raise_socket_error("getnameinfo", error); } sockaddr = rb_assoc_new(rb_str_new_cstr(hbuf), rb_str_new_cstr(pbuf)); break; } } return rb_ary_new3(7, afamily, sockaddr, pfamily, socktype, protocol, canonname, inspectname); }