Skip to main content
GameDev.net gamedev.net
🔒 Locked

changing ip header (TTL) with winsock

Started by Zoomby Mar 3, 2003 at 12:54 PM 1 replies 2.6k views
Original Post
Zoomby
Zoomby
hi, is is possible to change the "time to live" value in a packet without needing to use raw sockets? bye chris
x33
x33
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
Zoomby
Zoomby
works fine! thanks a lot!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.