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/ |
> -----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