]>
cvs.zerfleddert.de Git - record-dvb/blob - mcast.c
6 #include <sys/socket.h>
12 int is_mcast(char *url
)
17 if (!strncasecmp("udp://",url
,6))
23 int open_mcast(char *url
)
25 static struct dvb_host
*dvbhost
= NULL
;
26 struct sockaddr_in server
;
35 dvbhost
= parse(&(url
[6]), "2000");
36 dvbhost
->socktype
= SOCK_DGRAM
;
39 if (resolve(dvbhost
, &server
) < 0) {
43 bzero(&mreq
, sizeof(mreq
));
44 mreq
.imr_multiaddr
= server
.sin_addr
;
45 mreq
.imr_interface
.s_addr
= htonl(INADDR_ANY
);
47 if ((fd
= socket(AF_INET
, SOCK_DGRAM
, IPPROTO_UDP
)) < 0) {
53 if (setsockopt(fd
, SOL_SOCKET
, SO_REUSEADDR
, &val
, sizeof(val
)) < 0) {
58 if (bind(fd
, (struct sockaddr
*)&server
, sizeof(server
)) < 0) {
63 if (setsockopt(fd
, IPPROTO_IP
, IP_ADD_MEMBERSHIP
, &mreq
, sizeof(mreq
)) < 0) {