As an addition to this message, how would one do the following?

When one connects to a remote IP address, we get a local port number as well
as a remote port number.  How do I find out what the local port number is?
For example:

>> z: open tcp://192.168.0.1:21
>> probe z

make object! [
    scheme: tcp
    host: 192.168.0.1
    port-id: 21
    user: none
    pass: none
    target: none
    path: none
    proxy: none
    access: none
    allow: none
    buffer-size: none
    limit: none
    handler: none
    status: none
    size: none
    date: none
    url: none
    sub-port: none
    locals: none
    state:
    make object! [
        flags: 524819
        misc: 80
        tail: 0
        num: 0
        with: "^M^/"
        custom: none
        index: 0
        func: 3
        fpos: 0
        inBuffer: none
        outBuffer: none
    ]
    timeout: none
]

We know we are connected to remote port 21, and we know by my netstat that:


Active Connections

  Proto  Local Address          Foreign Address        State
                ...stuff...
  TCP    davids:4403            server:ftp             ESTABLISHED
                ...stuff...

How would I know what my local port is?  z/port-id appears to be the remote
port when you open one, or the local port if you specify "tcp://".

David Logan

> [EMAIL PROTECTED] wrote:
> > Hi Deryk,
> >
> > Not sure if this is what you mean or not..
> >
> > If no port-id is specified, an available port will be allocated
> > (This example works in Rebol/View)
> >
> > my-conn: open tcp://
> > my-conn/port-id
> > ==2664
> > >> my-conn2: open/lines tcp://
> > >> my-conn2/port-id
> > == 2665
>
> Allen,
>
> Yeah, that's exactly what I was hunting for. Perhaps this should be
> documented. :)

http://www.rebol.com/howto.html#tcp.html

It is in the "how-to", under "Opening an Listen Port"
but I didn't see it mentioned in the other docs.


Cheers,

Allen K


Reply via email to