socket.setTTL(ttl)
ttl
<integer>
设置 IP_TTL
套接字选项。
一般来说,TTL 表示"生存时间",这里特指一个 IP 数据包传输时允许的最大跳步数。
当 IP 数据包每向前经过一个路由或网关时,TTL 值减 1,若经过某个路由时,TTL 值被减至 0,便不再继续向前传输。
比较有代表性的是,为了进行网络情况嗅探或者多播而修改 TTL 值。
ttl
参数可以是 0
到 255
之间。
在大多数系统上,默认值是 64
。
This method throws EBADF
if called on an unbound socket.
ttl
<integer>
Sets the IP_TTL
socket option. While TTL generally stands for "Time to Live",
in this context it specifies the number of IP hops that a packet is allowed to
travel through. Each router or gateway that forwards a packet decrements the
TTL. If the TTL is decremented to 0 by a router, it will not be forwarded.
Changing TTL values is typically done for network probes or when multicasting.
The ttl
argument may be between between 1 and 255. The default on most systems
is 64.
This method throws EBADF
if called on an unbound socket.