Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] get free local port for script?



On Sat, Mar 17, 2007 at 10:55:57PM +0900, Stephen J. Turnbull wrote:
> Edward Wright writes:
> 
>  > I'd like to programmatically access a remote service over an ssh tunnel.
>  > I need a free local port to use, and I'm wondering the best way to get
>  > one.
> 
> I don't understand.  Some will be listening on port P only if you put
> it there.  What's wrong with: Pick a port, grep for it in
> /etc/services, and if you discover that it's either not there or is
> registered only to services you'll never use, use it?

My understanding is that when you make a (in this case) tcp connection
to a remote host, a port is assigned on the local host in some sequence
order.... therefore, I would think that at any given time, any given
port could be in use. Am I missing something?

Ed


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links