PHP Socket TTL
Posted: Sat Feb 27, 2010 4:16 pm
Hi there,
I am creating a PHP ping utility and was wondering if there was a way to read/set the socket TTL option?
It looks like in C++ and other languages you can but can't find any way of setting it in PHP.
What I need to do is set a socket option for the IP protocol (getprotobyname("ip")) for the option IP_TTL but IP_TTL isn't defined anywhere. It looks like being 4 on most UNIX systems but if I try this manually (not a good idea anyway) but still no joy.
Is what I am using to create the socket.
When I get a reply including the IP header the TTL is contained but I can find no options to read/write this value.
I hope I have been clear - any help is much appreciated.
Regards,
Dave.
I am creating a PHP ping utility and was wondering if there was a way to read/set the socket TTL option?
It looks like in C++ and other languages you can but can't find any way of setting it in PHP.
What I need to do is set a socket option for the IP protocol (getprotobyname("ip")) for the option IP_TTL but IP_TTL isn't defined anywhere. It looks like being 4 on most UNIX systems but if I try this manually (not a good idea anyway) but still no joy.
Code: Select all
$socket=socket_create(AF_INET,SOCK_RAW,1);
When I get a reply including the IP header the TTL is contained but I can find no options to read/write this value.
I hope I have been clear - any help is much appreciated.
Regards,
Dave.