+#include <features.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <time.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <strings.h>
+
+#include "mcast.h"
+
+#define CHUNKSIZE 1500
+
+int main(int argc, char **argv)
+{
+ char *url;
+ int bytes, written, i;
+ int in;
+ char buffer[CHUNKSIZE];
+
+ if (argc == 2) {
+ url = argv[1];
+ } else {
+ fprintf(stderr,"Syntax: %s URL\n", argv[0]);
+ exit(EXIT_FAILURE);
+ }
+
+ if ((in = open_mcast(url)) < 0) {
+ fprintf(stderr,"Can't open url %s!\n",url);
+ exit(EXIT_FAILURE);
+ }
+
+ while(1) {
+ if ((bytes = recv(in, buffer, CHUNKSIZE, 0)) < 1) {
+ perror("recv");
+ exit(EXIT_FAILURE);
+ }
+
+ written = 0;
+ do {
+ if ((i = write(STDOUT_FILENO, buffer, bytes-written)) < 0) {
+ perror("write");
+ exit(EXIT_FAILURE);
+ }
+ written += i;
+ } while(written < bytes);
+ }
+
+ close(in);
+
+ return EXIT_SUCCESS;
+}