You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Roy Smith <ro...@panix.com> on 2010/08/17 14:54:58 UTC

How to discover the bound port for a TServerSocket?

I'm trying to use TServerSocket (in java) without specifying a port.  The classic pattern is something like:

ServerSocket sock();
sock.bind(0);
int myPort = sock.getLocalPort();

but TServerSocket doesn't appear to have the getLocalPort() functionality.  Am I missing something, or does this really not exist?


Re: How to discover the bound port for a TServerSocket?

Posted by Bryan Duxbury <br...@rapleaf.com>.
If this doesn't work, open a ticket.

On Aug 17, 2010 6:06 AM, "Phillip B Oldham" <ph...@gmail.com>
wrote:
> I believe TServerSocket is a wrapper. Try something like
> `sock.socket.getLocalPort()` (if it's public).
>
> On Tue, Aug 17, 2010 at 1:54 PM, Roy Smith <ro...@panix.com> wrote:
>> I'm trying to use TServerSocket (in java) without specifying a port.  The
classic pattern is something like:
>>
>> ServerSocket sock();
>> sock.bind(0);
>> int myPort = sock.getLocalPort();
>>
>> but TServerSocket doesn't appear to have the getLocalPort()
functionality.  Am I missing something, or does this really not exist?
>>
>>
>
>
>
> --
> Phillip B Oldham
> phillip.oldham@gmail.com
> +44 (0) 7525 01 09 01

Re: How to discover the bound port for a TServerSocket?

Posted by Phillip B Oldham <ph...@gmail.com>.
I believe TServerSocket is a wrapper. Try something like
`sock.socket.getLocalPort()` (if it's public).

On Tue, Aug 17, 2010 at 1:54 PM, Roy Smith <ro...@panix.com> wrote:
> I'm trying to use TServerSocket (in java) without specifying a port.  The classic pattern is something like:
>
> ServerSocket sock();
> sock.bind(0);
> int myPort = sock.getLocalPort();
>
> but TServerSocket doesn't appear to have the getLocalPort() functionality.  Am I missing something, or does this really not exist?
>
>



-- 
Phillip B Oldham
phillip.oldham@gmail.com
+44 (0) 7525 01 09 01