Fixed bug in client which didn't send the null byte. added fork for notify-send
authorDylan Lloyd <dylan@dylansserver.com>
Sun, 29 Jan 2012 19:43:23 +0000 (14:43 -0500)
committerDylan Lloyd <dylan@dylansserver.com>
Sun, 29 Jan 2012 19:43:23 +0000 (14:43 -0500)
client.c
server.c

index 57078dc..463dd38 100644 (file)
--- a/client.c
+++ b/client.c
@@ -36,8 +36,8 @@ int main(int argc, char *argv[])
        int rv;
        char s[INET6_ADDRSTRLEN];
 
-       if (argc != 2) {
-           fprintf(stderr,"usage: client hostname\n");
+       if (argc != 3) {
+           fprintf(stderr,"usage: client hostname 'message'\n");
            exit(1);
        }
 
@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
                return 2;
        }
 
-    if (send(sockfd, "Hello, world!", 13, 0) == -1)
+    if (send(sockfd, argv[2], strlen(argv[2])+1, 0) == -1)
         perror("send");
 
     printf("connected\n");
index 1da2bcd..df70fb4 100644 (file)
--- a/server.c
+++ b/server.c
@@ -122,6 +122,8 @@ int main(void)
             }
             buf[100] = '\0';
             printf("server: recieved '%s'\n", buf);
+            if (!fork())
+                execl("/home/dylan/test", "irssi", buf, NULL);
                        close(new_fd);
                        exit(0);
                }