информационная безопасность
без паники и всерьез
 подробно о проектеRambler's Top100
Сетевые кракеры и правда о деле ЛевинаЗа кого нас держат?Все любят мед
BugTraq.Ru
Русский BugTraq
 Анализ криптографических сетевых... 
 Модель надежности двухузлового... 
 Специальные марковские модели надежности... 
 Три миллиона электронных замков... 
 Doom на газонокосилках 
 Умер Никлаус Вирт 
главная обзор RSN блог библиотека закон бред форум dnet о проекте
bugtraq.ru / форум / programming
Имя Пароль
ФОРУМ
все доски
FAQ
IRC
новые сообщения
site updates
guestbook
beginners
sysadmin
programming
operating systems
theory
web building
software
hardware
networking
law
hacking
gadgets
job
dnet
humor
miscellaneous
scrap
регистрация





Легенда:
  новое сообщение
  закрытая нитка
  новое сообщение
  в закрытой нитке
  старое сообщение
  • Напоминаю, что масса вопросов по функционированию форума снимается после прочтения его описания.
  • Новичкам также крайне полезно ознакомиться с данным документом.
[WinSock UDP Multicast] лови кусок MSDN 16.12.04 21:34  Число просмотров: 4629
Автор: NKritsky <Nickolay A. Kritsky> Статус: Elderman
<"чистая" ссылка>
Joining and Leaving a Multicast Group
Before a host can receive IP multicast datagrams, it must become a member of one or more IP multicast groups. The following code example shows how a process requests to join a multicast group by using the setsockopt function.

struct ip_mreq mreq;
// mreq is the ip_mreqstructure
{
struct in_addr imr_multiaddr; //The multicast group to join
struct in_addr imr_interface; //The interface to join on
}

#define RECV_IP_ADDR "225.6.7.8" // An arbitrary multicast address

mreq.imr_multiaddr.s_addr = inet_addr(RECV_IP_ADDR);
mreq.imr_interface.s_addr = INADDR_ANY;
err = setsockopt(
sock,
IPPROTO_IP,
IP_ADD_MEMBERSHIP,
(char*)&mreq,
sizeof(mreq));
A socket must bind to an address before calling setsockopt.

Every multicast group membership is associated with a single interface. It is possible to join the same group on more than one interface. To choose the default multicast interface, use INADDR_ANY as the address for imr_interface. To choose a specific interface capable of multicasting, use one of the host's local addresses.

The following code example shows how to leave a multicast group.

struct ip_mreq mreq;
setsockopt(
sock,
IPPROTO_IP,
IP_DROP_MEMBERSHIP,
(char*)&mreq,
sizeof(mreq));
The memberships associated with a socket are dropped when the socket is closed, or the process holding the socket is terminated. However, more than one socket may claim a membership in a particular group, and the host remains a member of that group until the last membership is dropped.
<programming> Поиск 






Rambler's Top100
Рейтинг@Mail.ru


  Copyright © 2001-2024 Dmitry Leonov   Page build time: 0 s   Design: Vadim Derkach