IP_MULTICAST_TTL(2const)

IP_MULTICAST_TTL2const

Time-to-live value of outgoing multicast packets

Usage

#include <netinet/in.h>  /* Definition of IP* constants */
#include <sys/socket.h>

int setsockopt(int sockfd, IPPROTO_IP, IP_MULTICAST_TTL, const int *ttl, sizeof(int)); int getsockopt(int sockfd, IPPROTO_IP, IP_MULTICAST_TTL, int *ttl, sizeof(int));

Library

Standard C library (libc, -lc)

Overview

Set or read the time-to-live value of outgoing multicast packets for this socket.

The default is 1 which means that multicast packets don't leave the local network unless the user program explicitly requests it.

Errors

See IPPROTO_IP(2const). See setsockopt(2). See ip(7).

Caveats

It is very important for multicast packets to set the smallest TTL possible.

History

Linux 1.2.

From man-pages 6.19-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.