foo-wm

(Archived) Experimental Zooming IPC-based WM
git clone http://milesalan.com/git/foo-wm
Log | Files | Refs | Mirror | README | LICENSE

client.c (857B)


      1 #include <stdio.h>
      2 #include <stdlib.h>
      3 #include <string.h>
      4 #include <sys/socket.h>
      5 #include <sys/un.h>
      6 #include <unistd.h>
      7 
      8 int main(int argc, char **argv) {
      9   int socketFd;
     10   struct sockaddr_un socketAddress;
     11   int bufferSize = 256;
     12   char buffer[bufferSize];
     13 
     14   /* Initialize the sockaddr_un struct */
     15   socketAddress.sun_family = AF_UNIX;
     16   strcpy(socketAddress.sun_path, argv[1]);
     17 
     18   /* Setup the socket, Connect, and Send the send CL Arg */
     19   socketFd = socket(AF_UNIX, SOCK_STREAM, 0);
     20   connect(socketFd, (struct sockaddr *)&socketAddress, sizeof(socketAddress));
     21   send(socketFd, argv[2], strlen(argv[2]), 0);
     22 
     23   /* Check if we recieved a response */
     24   while (recv(socketFd, buffer, sizeof(buffer), 0) > 0) {
     25     buffer[sizeof(buffer)] = '\0';
     26     printf("%s", buffer);
     27   }
     28 
     29   /* Close and return */
     30   printf("\n");
     31   close(socketFd);
     32   return 0;
     33 }