[Boost-users] Get IP address of a client

81 views
Skip to first unread message

Rouven Walter

unread,
May 19, 2010, 8:26:17 AM5/19/10
to boost...@lists.boost.org
 
Hello,

I use the asio boost library for network traffic. Is there a way to get the IP address of a client directly if the server receives data over a socket object, so that the IP address has not to be sent within the data.
Normally this should be possible, since TCP pakets holds the ip address of receiver and sender in the header information. But how can I get these header information with the asio library?

Best Regards, Cyraid
  

NEU: WEB.DE DSL für 19,99 EUR/mtl. und ohne Mindest-Laufzeit!   
http://produkte.web.de/go/02/

--
You received this message because you are subscribed to the Google Groups "BOOST Archives" group.
To post to this group, send email to boost...@googlegroups.com.
To unsubscribe from this group, send email to boost-list+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/boost-list?hl=en.

Casimiro, Daniel C CIV NUWC NWPT

unread,
May 19, 2010, 9:54:05 AM5/19/10
to boost...@lists.boost.org

> -----Original Message-----
> From: boost-use...@lists.boost.org
> [mailto:boost-use...@lists.boost.org] On Behalf Of
> Rouven Walter
> Sent: Wednesday, May 19, 2010 8:26
> To: boost...@lists.boost.org
> Subject: [Boost-users] Get IP address of a client
>
>
> Hello,
>
> I use the asio boost library for network traffic. Is there a
> way to get the IP address of a client directly if the server
> receives data over a socket object, so that the IP address
> has not to be sent within the data.
> Normally this should be possible, since TCP pakets holds the
> ip address of receiver and sender in the header information.
> But how can I get these header information with the asio library?

There is an overload of the async_accept member function that provides this information:

template<
typename SocketService,
typename AcceptHandler>
void async_accept(
basic_socket< protocol_type, SocketService > & peer,
endpoint_type & peer_endpoint,
AcceptHandler handler);

More information:
http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/reference/basic_socket_acceptor/async_accept/overload2.html

There is an equivalent in the synchronous API.

~Dan

Reply all
Reply to author
Forward
0 new messages