[Live-devel] Getting source IP address

Ross Finlayson finlayson at live555.com
Fri Jul 21 04:56:47 PDT 2006


>When I receive the packets in the client side, I would like to get the
>source IP address and port number from where the packets are coming. I have
>added the following lines in networkReadHandler() function
>MultiFramedRTPSource.cpp file.
>
>******************************************************************
>
>   const struct in_addr in_addr1= source->RTPgs()->groupAddress();
>   char *ip = inet_ntoa(in_addr1);
>
>   const portNumBits port= source->RTPgs()->portnum();
>
>*******************************************************************
>
>In the above statement, I am getting the IP address (variable ip) of the
>client machine instead of server. Port number is also same.
>
>How do I get the server IP address.

You do this my modifying "MultiFramedRTPSource.cpp", but not in the 
way that you have done.

Instead, note the "fromAddress" parameter to the call to 
"handleRead()" in "BufferedPacket::fillInData()".  This (result) 
parameter will contain the source IP address and port for the 
received RTP packet.

-- 

Ross Finlayson
Live Networks, Inc.
http://www.live555.com/


More information about the live-devel mailing list