Class: SOCKSSocket

Inherits:
TCPSocket show all
Defined in:
sockssocket.c,
sockssocket.c

Overview

SOCKS is an Internet protocol that routes packets between a client and a server through a proxy server. SOCKS5, if supported, additionally provides authentication so only authorized users may access a server.

Instance Method Summary collapse

Methods inherited from TCPSocket

gethostbyname

Methods inherited from IPSocket

#addr, getaddress, #peeraddr, #recvfrom

Methods inherited from BasicSocket

#close_read, #close_write, #connect_address, #do_not_reverse_lookup, do_not_reverse_lookup, do_not_reverse_lookup=, #do_not_reverse_lookup=, for_fd, #getpeereid, #getpeername, #getsockname, #getsockopt, #local_address, #recv, #recv_nonblock, #recvmsg, #recvmsg_nonblock, #remote_address, #send, #sendmsg, #sendmsg_nonblock, #setsockopt, #shutdown

Constructor Details

#new(host, serv) ⇒ Object

Opens a SOCKS connection to host via the SOCKS server serv.


21
22
23
24
25
26
27
28
29
30
31
32
# File 'sockssocket.c', line 21

static VALUE
socks_init(VALUE sock, VALUE host, VALUE serv)
{
    static int init = 0;

    if (init == 0) {
	SOCKSinit("ruby");
	init = 1;
    }

    return rsock_init_inetsock(sock, host, serv, Qnil, Qnil, INET_SOCKS);
}

Instance Method Details

#closeObject

Closes the SOCKS connection.


39
40
41
42
43
44
45
46
47
48
49
50
# File 'sockssocket.c', line 39

static VALUE
socks_s_close(VALUE sock)
{
    rb_io_t *fptr;

    if (rb_safe_level() >= 4 && !OBJ_TAINTED(sock)) {
	rb_raise(rb_eSecurityError, "Insecure: can't close socket");
    }
    GetOpenFile(sock, fptr);
    shutdown(fptr->fd, 2);
    return rb_io_close(sock);
}