Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

How do I increase the TTL on a socket?

by c-era (Curate)
on May 12, 2000 at 21:42 UTC ( [id://11334]=perlquestion: print w/replies, xml ) Need Help??

c-era has asked for the wisdom of the Perl Monks concerning the following question:

I have to write an ICMP program, and the TTL is 1. Does anyone know how to change the TTL?
use Socket; $host="somehost"; socket(SOCK,PF_INET, SOCK_RAW, getprotobyname('icmp')) || die $!; send (SOCK, pack("C2 S5", 17, 0, 0xc898,0x2667,0,0,0), 0x04,sockaddr_i +n (0,inet_aton($host)) ) || die $!;

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: How do I increase the TTL on a socket?
by c-era (Curate) on May 16, 2000 at 18:40 UTC
    I found my own answer:
    use Socket; $host="somehost"; socket(SOCK,PF_INET, SOCK_RAW, getprotobyname('icmp')) || die $!; send (SOCK, pack("C2 S5", 17, 0, 0xc898,0x2667,0,0,0),0,sockaddr_in (0 +,inet_aton($host))) || die $!; ^
    The flag was just set wrong, I also found out how to change the TTL (at least for Solaris):
    setsockopt (SOCK,0,4,<TTL>);
Re: How do I increase the TTL on a socket?
by Anonymous Monk on Jul 13, 2001 at 18:39 UTC
    Ans: ==== think u could do that using setsockoption() which is available in win/unix ======Fhani

    Originally posted as a Categorized Answer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11334]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2024-04-23 12:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found