/***** stream socket example: client.c *****/ 
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>      /* UNIX domain header */

int main()
{ int soc;
  char buf[256];
  struct sockaddr_un self = {AF_UNIX, "clientsoc"}; 
  struct sockaddr_un peer = {AF_UNIX, "serversoc"}; 
      soc = socket(AF_UNIX, SOCK_STREAM, 0);       /* (a) */
      bind(soc, &self, sizeof(self));              /* (b) */
  /* request connection to serversoc */
      if (connect(soc,(struct sockaddr *)&peer, sizeof(peer)) == -1) /* (c) */
      {  perror("client:connect"); close(soc);
         unlink(self.sun_path); exit(1); 
      }
      write(soc, "hello from client", 18);         /* (d) */
      read(soc, buf, sizeof(buf));                 /* (e) */
      printf("SERVER ECHOED: %s\n", buf);
      close(soc);   unlink(self.sun_path);
      return(0);
}
/***** end of client.c *****/ 

