]>
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 struct dvb_host
*dvbhost
= NULL
;
26 struct sockaddr_in server
;
34 dvbhost
= parse(&(url
[6]), "2000");
35 dvbhost
->socktype
= SOCK_DGRAM
;
37 if (resolve(dvbhost
, &server
) < 0) {
41 bzero(&mreq
, sizeof(mreq
));
42 mreq
.imr_multiaddr
= server
.sin_addr
;
43 mreq
.imr_interface
.s_addr
= htonl(INADDR_ANY
);
45 if ((fd
= socket(AF_INET
, SOCK_DGRAM
, IPPROTO_UDP
)) < 0) {
51 if (setsockopt(fd
, SOL_SOCKET
, SO_REUSEADDR
, &val
, sizeof(val
)) < 0) {
56 if (bind(fd
, (struct sockaddr
*)&server
, sizeof(server
)) < 0) {
61 if (setsockopt(fd
, IPPROTO_IP
, IP_ADD_MEMBERSHIP
, &mreq
, sizeof(mreq
)) < 0) {