# How i can open one port from computer

**URL:** <https://www.ruby-forum.com/t/how-i-can-open-one-port-from-computer/179365>\
**Category:** Ruby\
**Created:** [November 23, 2009, 2:59pm UTC](https://www.ruby-forum.com/t/how-i-can-open-one-port-from-computer/179365 "2009-11-23T14:59:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sql\_injection](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbe5ce/32.png) [@sql\_injection](https://www.ruby-forum.com/u/sql_injection)\
**Post date:** [November 23, 2009, 2:59pm UTC](https://www.ruby-forum.com/t/how-i-can-open-one-port-from-computer/179365/1 "2009-11-23T14:59:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sql\_injection](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbe5ce/32.png) [@sql\_injection](https://www.ruby-forum.com/u/sql_injection)\
**Post date:** [November 23, 2009, 3:57pm UTC](https://www.ruby-forum.com/t/how-i-can-open-one-port-from-computer/179365/2 "2009-11-23T15:57:34Z")

</div>

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/docs/ProgrammingRuby/html/lib_network.html)  
[http://www.ruby-doc.org/stdlib/libdoc/socket/rdoc/index.html](http://www.ruby-doc.org/stdlib/libdoc/socket/rdoc/index.html)

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

> **[Learn How to Blog and Build Websites for Profit!](https://heyblogging.com)**
>
> Ready to take your blogging skills to the next level? Learn how to build a website that generates income and sets you up for success.

---

<div class="post-metadata">

**Author:** ![sql\_injection](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbe5ce/32.png) [@sql\_injection](https://www.ruby-forum.com/u/sql_injection)\
**Post date:** [November 23, 2009, 5:50pm UTC](https://www.ruby-forum.com/t/how-i-can-open-one-port-from-computer/179365/3 "2009-11-23T17:50:44Z")

</div>

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](http://www.yahoo.com)’)

ok whats defrent between this code and befor code ?

thank you so mach
