(no commit message)
authorSapan Bhatia <sapanb@cs.princeton.edu>
Tue, 24 Mar 2009 18:44:25 +0000 (18:44 +0000)
committerSapan Bhatia <sapanb@cs.princeton.edu>
Tue, 24 Mar 2009 18:44:25 +0000 (18:44 +0000)
fd_bmsocket.c

index f9f7c91..74d8414 100644 (file)
@@ -2,6 +2,7 @@
 #include <sys/socket.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <errno.h>
 #include "fdpass.h"
 
 unsigned int rcvbuf = 16*1024*1024;
@@ -16,6 +17,14 @@ int main(int argc, char *argv[]) {
     sscanf(argv[2],"%d", &control_channel_fd);
 
     magic_socket = socket(AF_INET, SOCK_STREAM, 0);
-    setsockopt(magic_socket, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(unsigned int));
+
+    if (magic_socket == -1) {
+        printf("Error creating socket: %d\n", errno);
+        exit(1);
+    }
+    if (setsockopt(magic_socket, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(unsigned int))) {
+        printf("Error calling setsockopt: %d\n", errno);
+        exit(1);
+    }
     send_fd(control_channel_fd, magic_socket);
 }