Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Specifying ports when creating sockets?

Reply
Thread Tools

Specifying ports when creating sockets?

 
 
Alex Maccaw
Guest
Posts: n/a
 
      06-05-2009

In TCP, when you create a socket to a particular address, the OS chooses
a free port number.

I'd like to either specify that port number, or find out that port
number.

I can easily find the port number like so:
socket.addr[1]

However, that fails when the IO stream is closed. I need to find out the
port number even if the connection is never made. I'm not sure this is
possible, which is why I think the first approach, specifying the port
number, is the way to go.

If you're wondering why I'm doing this, it's to do with STUNT.

Can anybody provide any pointers?
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Alex Maccaw
Guest
Posts: n/a
 
      06-05-2009
Alex Maccaw wrote:
>
> In TCP, when you create a socket to a particular address, the OS chooses
> a free port number.
>
> I'd like to either specify that port number, or find out that port
> number.
>
> I can easily find the port number like so:
> socket.addr[1]
>
> However, that fails when the IO stream is closed. I need to find out the
> port number even if the connection is never made. I'm not sure this is
> possible, which is why I think the first approach, specifying the port
> number, is the way to go.
>
> If you're wondering why I'm doing this, it's to do with STUNT.
>
> Can anybody provide any pointers?


Ok, somebody has kindly let me know that TCPSocket takes 4 options,
including a local port - oops!

That should solve the issue.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Type of actual ports is not compatible with type of ports of entity. mreister VHDL 1 05-25-2010 11:30 AM
Recommendations Please for a PCI card w/ two USB 2 Ports and FireWaire Ports Mike Digital Photography 27 02-26-2006 12:54 AM
Specifying vector length in the function output valentin tihomirov VHDL 1 06-28-2005 06:52 PM
Manually specifying the shell Adam Preble Perl 0 03-17-2005 01:44 AM
Specifying generics in configuration valentin tihomirov VHDL 14 01-07-2004 05:27 PM



Advertisments