Flowdock
getaddrinfo(p1, p2, p3 = v3, p4 = v4, p5 = v5, p6 = v6) public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
static VALUE
sock_s_getaddrinfo(int argc, VALUE *argv)
{
    VALUE host, port, family, socktype, protocol, flags, ret;
    char *ap;
    struct addrinfo hints, *res;

    rb_scan_args(argc, argv, "24", &host, &port, &family, &socktype, &protocol, &flags);

    MEMZERO(&hints, struct addrinfo, 1);
    if (NIL_P(family)) {
        hints.ai_family = PF_UNSPEC;
    }
    else if (FIXNUM_P(family)) {
        hints.ai_family = FIX2INT(family);
    }
    else if ((ap = StringValuePtr(family)) != 0) {
        if (strcmp(ap, "AF_INET") == 0) {
            hints.ai_family = PF_INET;
        }
#ifdef INET6
        else if (strcmp(ap, "AF_INET6") == 0) {
            hints.ai_family = PF_INET6;
        }
#endif
    }

    if (!NIL_P(socktype)) {
        hints.ai_socktype = NUM2INT(socktype);
    }
    if (!NIL_P(protocol)) {
        hints.ai_protocol = NUM2INT(protocol);
    }
    if (!NIL_P(flags)) {
        hints.ai_flags = NUM2INT(flags);
    }
    res = sock_getaddrinfo(host, port, &hints, 0);

    ret = make_addrinfo(res);
    freeaddrinfo(res);
    return ret;
}
Register or log in to add new notes.