# Socks v5 protocol

**URL:** <https://www.ruby-forum.com/t/socks-v5-protocol/140170>\
**Category:** Ruby\
**Created:** [June 11, 2008, 3:22pm UTC](https://www.ruby-forum.com/t/socks-v5-protocol/140170 "2008-06-11T15:22:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bloodnix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/977dab/32.png) [@bloodnix](https://www.ruby-forum.com/u/bloodnix)\
**Post date:** [June 11, 2008, 3:22pm UTC](https://www.ruby-forum.com/t/socks-v5-protocol/140170/1 "2008-06-11T15:22:01Z")

</div>

Hello, only I start to study this language. And at once a greater  
problem: ((

I can not understand connection under the report socks5 in any way, and  
connection, inquiry of the version and methods of authorization passes  
successfully, and here when I try to transfer the removed host and port  
I socks-server does not see the address in inquiry, in broad gullies  
writes, approximately it:

[11/Jun/2008:16:45:39 MSD] [19267] 192.168.0.9 “” “CONNECT” CONNREFUSED  
0 0 - (192.168.0.9:51012 -\> 210.199.9.0:0)  
[11/Jun/2008:16:45:39 MSD] [19270] [ERRO] $ConnectServing$: (Connection  
timed out).  
[11/Jun/2008:16:45:39 MSD] [19270] 192.168.0.9 “” “CONNECT” CONNREFUSED  
0 0 - (192.168.0.9:51014 -\> 210.199.9.0:0)  
[11/Jun/2008:16:45:39 MSD] [19272] [ERRO] $ConnectServing$: (Connection  
timed out).  
[11/Jun/2008:16:45:39 MSD] [19272] 192.168.0.9 “” “CONNECT” CONNREFUSED  
0 0 - (192.168.0.9:51016 -\> 210.199.9.0:0)

And here a code of connection:

…  
sock.setHost(“194.67.23.111”,25)  
…  
def hextobin(str)  
temp = str.gsub("\s", “”);  
ret = []  
(0…temp.size()/2).each{|index| ret[index] = [temp[index\*2,  
2]].pack(“H2”)}  
return ret  
end

def setHost(domain,port)  
host=domain  
h=“05 01 00”  
if host =~ /^(\d+).(\d+).(\d+).(\d+)$/  
ip=[$1.to\_i,$2.to\_i,$3.to\_i,$4.to\_i].pack(‘CCC’)  
h+=" 01 " +[host.size].pack(‘C’)+ip  
else  
h+=" 03" + [host.size].pack(‘C’) + host  
end  
h+=[port].pack(‘n’)  
@sock.write(hextobin(h))  
t=@sock.recv(1).unpack(“H\*”).to\_s  
return t[3…3]  
end  
…

As we see, I ask ip: 194.67.23.111:25, and up to socks-server reaches:  
210.199.9.0:0… I Turn out somehow not so I pack data: (((… Prompt  
please, that can be not so: (((

---

<div class="post-metadata">

**Author:** ![bloodnix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/977dab/32.png) [@bloodnix](https://www.ruby-forum.com/u/bloodnix)\
**Post date:** [June 11, 2008, 3:31pm UTC](https://www.ruby-forum.com/t/socks-v5-protocol/140170/2 "2008-06-11T15:31:10Z")

</div>

2008/6/11 Tannev V. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 0 0 - (192.168.0.9:51012 → 210.199.9.0:0)  
> And here a code of connection:  
> return ret  
> end  
> 210.199.9.0:0… I Turn out somehow not so I pack data: (((… Prompt  
> please, that can be not so: (((

I do not know SOCKS but “CONNREFUSED” usually indicates a network issue,  
namely:

- firewall blocks access
- there is nothing listening on the socket
- maybe even system is down.

Also, it seems weird that you want to access port 0 (the log says  
“210.199.9.0:0”) - AFAIK this is reserved and not possible anyways.

Cheers

robert

---

<div class="post-metadata">

**Author:** ![bloodnix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/977dab/32.png) [@bloodnix](https://www.ruby-forum.com/u/bloodnix)\
**Post date:** [June 11, 2008, 3:38pm UTC](https://www.ruby-forum.com/t/socks-v5-protocol/140170/3 "2008-06-11T15:38:43Z")

</div>

I wish to get access to:  
194.67.23.111:25,  
but probably data spoil, or I incorrectly send them as socks-server,  
thinks, that I want will be connected to:  
210.199.9.0:0…

sock.setHost (" 194.67.23.111", 25)

And up to a server why that other data reach: (
