+ if (resolve(dvbhost, &server) < 0) {
+ return -1;
+ }
+
+ bzero(&mreq, sizeof(mreq));
+ mreq.imr_multiaddr = server.sin_addr;
+ mreq.imr_interface.s_addr = htonl(INADDR_ANY);
+
+ if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
+ perror("socket");
+ return -1;
+ }
+
+ val = 1;
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) < 0) {
+ perror("setsockopt");
+ return -1;
+ }
+
+ if (bind(fd, (struct sockaddr*)&server, sizeof(server)) < 0) {
+ perror("bind");
+ return -1;
+ }
+
+ if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) {
+ perror("setsockopt");
+ return -1;
+ }