How i can open one port from computer

hi

im writing one program with Ruby

and now i need to open one port example port 1133 from TCP

now i wanna Ruby doese it to me

means ruby come and opening port 1133 TCP

now what should i do ?

if you have source code or any code for help me please but here ,

thank you for your

Sajjad S. wrote:

and now i need to open one port example port 1133 from TCP

now i wanna Ruby doese it to me

means ruby come and opening port 1133 TCP

now what should i do ?

You would use the ‘socket’ library. See
http://www.ruby-doc.org/docs/ProgrammingRuby/html/lib_network.html
http://www.ruby-doc.org/stdlib/libdoc/socket/rdoc/index.html

Google for “ruby socket API” turns up tutorials such as

1 :

ok , it was good but i cant underestand it .

for example i wanna a source code it opening port 2121

now if you have please put here ,


2 :

in this code :

require ‘socket’
puts “Enter Site Name :”
x=gets
a = IPSocket.getaddress(x)

after run wil come this error :

s.rb:4:in `getaddress’: newline at the end of hostname (SocketError)
from s.rb:4

now whats is my problem ?

i wanna after got site name show ip addres of that site to me .

but this code is working :

require ‘socket’

a = IPSocket.getaddress(‘www.yahoo.com’)

ok whats defrent between this code and befor code ?

thank you so mach