Re: [gnet] IP address of a TCP client



All right. I got it now. I have to use the socket returned by
gnet_tcp_socket_server_accept, which is the client and from which I can get the
inetaddr with gnet_tcp_socket_get_inetaddr. Then, I have to call
gnet_inetaddr_get_canonical_name to have the IP of the client...

Thanks!

-Olivier

David Helder wrote:

> Right.  I think you want to call get_inetaddr on the client socket
> returned by the server socket, not the server socket.  There may be
> multiple client sockets associated with the server socket.
>
> David
>
> On Tue, 30 Oct 2001, Olivier Michel wrote:
>
> > David,
> >
> > I think you misunderstood my question: according to the doc,
> > gnet_tcp_socket_get_inetaddr() for a server doesn't return the address of
> > the client but only the localhost, which is pretty useless...
> > Instead, it would be great if it could return the IP of the connected
> > client. This is very useful when you want to send an UDP socket to a client
> > which just got connected via TCP.
> >
> > -Olivier
> >
> > Doc:
> > >  GInetAddr*  gnet_tcp_socket_get_inetaddr    (const GTcpSocket *socket);
> > >
> > > Get the address of the socket. If the socket is client socket, the
> > address is
> > > the address of the remote host it is connected to. If the socket is a
> > server
> > > socket, the address is the address of the local host. (Though you should
> > > use gnet_inetaddr_gethostaddr() to get the GInetAddr of the local host.)
> >
> > David Helder wrote:
> >
> > > Yes, use gnet_tcp_socket_get_inetaddr()
> > >
> > > David
> > >
> > > On Fri, 21 Sep 2001, Olivier Michel wrote:
> > >
> > > > Hello,
> > > >
> > > > How is it possible with gnet to know the IP address of a remote client
> > > > connecting to a server via a TCP socket ?
> > > > In SDL_net, there is a very handy function for this:
> > > > SDLNet_TCP_GetPeerAddress(TCPsocket sock);
> > > > Is there any equivalent function in gnet ?
> > > >
> > > > Thanks,
> > > >
> > > > -Olivier
> > > >
> >
>
> --
>       __          _    __ David Helder - dhelder umich edu
>   ___/ /__ __  __(_)__/ / <http://www.eecs.umich.edu/~dhelder>
>  / _  / _ `/ |/ / / _  /  Jungle Monkey: <http://www.junglemonkey.net>
>  |_,_/|_,_/|___/_/|_,_/   Paper CD Case: <http://www.papercdcase.com>


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