You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by stream <st...@gmail.com> on 2011/10/24 00:55:13 UTC

how can i get the client's ip from the server of thrift

Hi.
i wanna get the remote client's ip in server, but i don't found such api that can get the ip address in thirft's lib.
i think mush someone k know how to do this.
can anyone help me . thanks....

Re: how can i get the client's ip from the server of thrift

Posted by stream <st...@gmail.com>.
i've just look at the TNonBlockingServerSocket and found its hard to put the client ip out.

protected TNonblockingSocket acceptImpl() throws TTransportException {
      if (serverSocket_ == null) {
        throw new TTransportException(TTransportException.NOT_OPEN, "No underlying server socket.");
      }
      try {
        SocketChannel socketChannel = serverSocketChannel.accept();
        if (socketChannel == null) {
          return null;
        }
	// here, how can i get the socketChannel, that seems its best the way by event flowing...
        TNonblockingSocket tsocket = new TNonblockingSocket(socketChannel);
        tsocket.setTimeout(clientTimeout_);
        return tsocket;
      } catch (IOException iox) {
        throw new TTransportException(iox);
      }
    }


On 2011-10-24, at 上午10:39, Mike Riley wrote:

> It looks like subclassing TServerSocket/TNonBlockingServerSocket (and
> your chosen server class) will allow you to access the IP address (or
> hostname) pretty easily right from the Sockets they manage so that's
> what you're shooting for I guess...
> 
> On Sun, Oct 23, 2011 at 10:15 PM, stream <st...@gmail.com> wrote:
>> well, is my fault ,not clear the description .
>> the library is Java... thank Mike firstly...
>> 
>> On 2011-10-24, at 上午9:20, Mike Riley wrote:
>> 
>>> plac
>> 
>> 


Re: how can i get the client's ip from the server of thrift

Posted by stream <st...@gmail.com>.
well , in fact , i don't believe the message from client... it can forge param, can't it?


On 2011-10-24, at 上午11:21, 陈竞 wrote:

> my method is  let you ip be the param of you interface , and tranfer to
> server, and so that server can get it
> 
> 2011/10/24 stream <st...@gmail.com>
> 
>> Well, i just wanna mark the record of client with its ip address.
>> i think is the best way to write a subclass of TServerSocket.
>> there are any other's?
>> 
>> 
>> On 2011-10-24, at 上午10:39, Mike Riley wrote:
>> 
>>> It looks like subclassing TServerSocket/TNonBlockingServerSocket (and
>>> your chosen server class) will allow you to access the IP address (or
>>> hostname) pretty easily right from the Sockets they manage so that's
>>> what you're shooting for I guess...
>>> 
>>> On Sun, Oct 23, 2011 at 10:15 PM, stream <st...@gmail.com> wrote:
>>>> well, is my fault ,not clear the description .
>>>> the library is Java... thank Mike firstly...
>>>> 
>>>> On 2011-10-24, at 上午9:20, Mike Riley wrote:
>>>> 
>>>>> plac
>>>> 
>>>> 
>> 
>> 
> 
> 
> -- 
> 陈竞,中科院计算技术研究所,高性能计算机中心
> Jing Chen HPCC.ICT.AC China


Re: how can i get the client's ip from the server of thrift

Posted by 陈竞 <cj...@gmail.com>.
my method is  let you ip be the param of you interface , and tranfer to
server, and so that server can get it

2011/10/24 stream <st...@gmail.com>

> Well, i just wanna mark the record of client with its ip address.
> i think is the best way to write a subclass of TServerSocket.
> there are any other's?
>
>
> On 2011-10-24, at 上午10:39, Mike Riley wrote:
>
> > It looks like subclassing TServerSocket/TNonBlockingServerSocket (and
> > your chosen server class) will allow you to access the IP address (or
> > hostname) pretty easily right from the Sockets they manage so that's
> > what you're shooting for I guess...
> >
> > On Sun, Oct 23, 2011 at 10:15 PM, stream <st...@gmail.com> wrote:
> >> well, is my fault ,not clear the description .
> >> the library is Java... thank Mike firstly...
> >>
> >> On 2011-10-24, at 上午9:20, Mike Riley wrote:
> >>
> >>> plac
> >>
> >>
>
>


-- 
陈竞,中科院计算技术研究所,高性能计算机中心
Jing Chen HPCC.ICT.AC China

Re: how can i get the client's ip from the server of thrift

Posted by stream <st...@gmail.com>.
Well, i just wanna mark the record of client with its ip address.
i think is the best way to write a subclass of TServerSocket.
there are any other's?


On 2011-10-24, at 上午10:39, Mike Riley wrote:

> It looks like subclassing TServerSocket/TNonBlockingServerSocket (and
> your chosen server class) will allow you to access the IP address (or
> hostname) pretty easily right from the Sockets they manage so that's
> what you're shooting for I guess...
> 
> On Sun, Oct 23, 2011 at 10:15 PM, stream <st...@gmail.com> wrote:
>> well, is my fault ,not clear the description .
>> the library is Java... thank Mike firstly...
>> 
>> On 2011-10-24, at 上午9:20, Mike Riley wrote:
>> 
>>> plac
>> 
>> 


Re: how can i get the client's ip from the server of thrift

Posted by Mike Riley <mi...@yelirekim.com>.
It looks like subclassing TServerSocket/TNonBlockingServerSocket (and
your chosen server class) will allow you to access the IP address (or
hostname) pretty easily right from the Sockets they manage so that's
what you're shooting for I guess...

On Sun, Oct 23, 2011 at 10:15 PM, stream <st...@gmail.com> wrote:
> well, is my fault ,not clear the description .
> the library is Java... thank Mike firstly...
>
> On 2011-10-24, at 上午9:20, Mike Riley wrote:
>
>> plac
>
>

Re: how can i get the client's ip from the server of thrift

Posted by stream <st...@gmail.com>.
well, is my fault ,not clear the description .
the library is Java... thank Mike firstly... 

On 2011-10-24, at 上午9:20, Mike Riley wrote:

> plac


Re: how can i get the client's ip from the server of thrift

Posted by Mike Riley <mi...@yelirekim.com>.
I think that's probably outside the scope of what responsibilities you
want to place on thrift, but depending on which server library you're
using you might be able to trivially adjust or subclass your Transport
to get the IP.

What server library (language) are you using?

~Mike

On Sun, Oct 23, 2011 at 6:55 PM, stream <st...@gmail.com> wrote:
> Hi.
> i wanna get the remote client's ip in server, but i don't found such api that can get the ip address in thirft's lib.
> i think mush someone k know how to do this.
> can anyone help me . thanks....