]> git.sesse.net Git - jam/commitdiff
Actually send (random) data.
authorsgunderson@bigfoot.com <>
Wed, 31 Jan 2007 21:47:10 +0000 (22:47 +0100)
committersgunderson@bigfoot.com <>
Wed, 31 Jan 2007 21:47:10 +0000 (22:47 +0100)
jam.c

diff --git a/jam.c b/jam.c
index 9f1a186a7647224b53238fef1ec89e00cd12c6bb..1da8fc84f282189882fe5a4eddc6ff732bbd50df 100644 (file)
--- a/jam.c
+++ b/jam.c
@@ -133,6 +133,10 @@ void *sender_worker(void *arg)
 {
        unsigned i;
        int sock;
+       char buf[65536];
+
+       for (i = 0; i < 65536; ++i)
+               buf[i] = rand() & 0xff;
 
        for (i = 0; i < 1000; ++i) {
                unsigned src_num = (unsigned)(num_sources * gen_uniform_random());
@@ -161,7 +165,23 @@ void *sender_worker(void *arg)
                
                fprintf(stderr, "connected\n");
 
-               // FIXME: send data here
+               while (num_bytes > 0) {
+                       unsigned bytes_to_send = num_bytes;
+                       unsigned ret;
+
+                       if (bytes_to_send > 65536) {
+                               bytes_to_send = 65536;  
+                       }
+
+                       ret = send(sock, buf, bytes_to_send, MSG_NOSIGNAL);
+                       if (ret == -1) {
+                               perror("send()");
+                               exit(1);
+                       }
+
+                       num_bytes -= ret;
+               }
+               fprintf(stderr, "sent\n");
 
                close(sock);
        }