HP Rp7410 BSD Sockets Interface Programmer's Guide - Page 116

Sending and Receiving IP Multicast, Datagrams

Page 116 highlights

Advanced Topics for Internet Datagram Sockets Sending and Receiving IP Multicast Datagrams Sending and Receiving IP Multicast Datagrams IP multicasting provides a mechanism for sending a single datagram to a group of systems. Normally, only systems that have joined the multicast group process the datagrams. Multicast datagrams are transmitted and delivered with the same "best effort" reliability as regular unicast IP datagrams. That is, the datagrams are not guaranteed to arrive intact at all members of the destination group or in the same order as the datagrams were sent. Membership in a multicast group is dynamic. That is, systems can join and leave groups at any time. A system remains a member of a multicast group until the last socket that joined the group is closed or has dropped membership in the group. A system can be a member of more than one group at a time. A system that has multiple interfaces might be a member of the same group on each interface. Sending IP Multicast Datagrams IP multicasting is supported only for AF_INET sockets of type SOCK_DGRAM and only on networks for which the interface supports multicasting. To send a multicast datagram, the application specifies an IP multicast address as the destination address in a sendto(2) call. For example: #include struct sockaddr_in servaddr; servaddr.sin_family = AF_INET; servaddr.sin_port = 12345; servaddr.sin_addr.s_addr = inet_addr("224.1.2.3"); sendto(s, buf, buflen, 0, &servaddr, sizeof(servaddr)); It is not necessary for the system to join a multicast group in order to send multicast datagrams. Each multicast datagram is sent from one network interface at a time, even if the system has joined the destination multicast group on more than one interface. The system administrator configures a default interface from which to send multicast datagrams. An application can override the default by setting a socket option IP_MULTICAST_IF to specify the outbound interface for datagrams sent through that socket. 116 Chapter 5

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196

116
Chapter 5
Advanced Topics for Internet Datagram Sockets
Sending and Receiving IP Multicast Datagrams
Sending and Receiving IP Multicast
Datagrams
IP multicasting provides a mechanism for sending a single datagram to a
group of systems. Normally, only systems that have joined the multicast
group process the datagrams.
Multicast datagrams are transmitted and delivered with the same “best
effort” reliability as regular unicast IP datagrams. That is, the
datagrams are not guaranteed to arrive intact at all members of the
destination group or in the same order as the datagrams were sent.
Membership in a multicast group is dynamic. That is, systems can join
and leave groups at any time. A system remains a member of a multicast
group until the last socket that joined the group is closed or has dropped
membership in the group. A system can be a member of more than one
group at a time. A system that has multiple interfaces might be a
member of the same group on each interface.
Sending IP Multicast Datagrams
IP multicasting is supported only for AF_INET sockets of type
SOCK_DGRAM and only on networks for which the interface supports
multicasting.
To send a multicast datagram, the application specifies an IP multicast
address as the destination address in a
sendto(2)
call. For example:
#include <netinet/in.h>
struct sockaddr_in servaddr;
servaddr.sin_family = AF_INET;
servaddr.sin_port = 12345;
servaddr.sin_addr.s_addr = inet_addr(“224.1.2.3”);
sendto(s, buf, buflen, 0, &servaddr, sizeof(servaddr));
It is not necessary for the system to join a multicast group in order to
send multicast datagrams.
Each multicast datagram is sent from one network interface at a time,
even if the system has joined the destination multicast group on more
than one interface. The system administrator configures a default
interface from which to send multicast datagrams. An application can
override the default by setting a socket option IP_MULTICAST_IF to
specify the outbound interface for datagrams sent through that socket.