PHP Socket TTL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
davex
Forum Contributor
Posts: 101
Joined: Sat Feb 27, 2010 4:10 pm
Location: Namibia

PHP Socket TTL

Post by davex »

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.

Code: Select all

 
$socket=socket_create(AF_INET,SOCK_RAW,1);
 
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.
Post Reply