Advertisement

changing ip header (TTL) with winsock

Started by March 03, 2003 12:54 PM
1 comment, last by Zoomby 21 years, 11 months ago
hi, is is possible to change the "time to live" value in a packet without needing to use raw sockets? bye chris
Just check the setsockopt() documentation. It is all written there.

The definition is:

int setsockopt (int sd, int level, int optname, const void *optval, socklen_t optlen);

sd - socket descriptor
level - the level of the parameter you want to set
optname - the parameter you want to set
optval - the pointer to the parameter value
optlen - the length of the parameter you want to set

In your case it should be:

int value = 128; //this should be something you want to set for TTL
setsockopt (sd, SOL_IP, IP_TTL, &value, sizeof(value));

By the way, there are plenty of other parameters you can set to control your socket... =)

[edited by - x33 on March 3, 2003 8:14:08 PM]
"I'll be Bach!" (c) Johann Sebastian Schwarzenegger
Advertisement
works fine! thanks a lot!

This topic is closed to new replies.

Advertisement