Search code examples
rubynetwork-programmingsocks

Close Socks Connection Ruby


1)How do I check what port ruby uses for TCP connections? 2)How do I make the last line of this code work?

require 'socksify'  #gem

TCPSocket::socks_server = 'localhost'
TCPSocket::socks_port = 9999 

#do stuff 

TCPSocket::socks_port = CLOSE SOCKS CONNECTION, GO BACK TO WHAT IT WAS BEFORE

Solution

  • TCPSocket::socks_server and TCPSocket::socks_port are nil prior to being set, so I think just do something like this:

    TCPSocket::socks_server = nil
    TCPSocket::socks_port = nil