skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

ipc_connected.c (381B)


      1 /* ISC license. */
      2 
      3 #include <skalibs/nonposix.h>
      4 #include <sys/socket.h>
      5 #include <sys/un.h>
      6 
      7 #include <skalibs/allreadwrite.h>
      8 #include <skalibs/socket.h>
      9 
     10 int ipc_connected (int s)
     11 {
     12   struct sockaddr_un sa ;
     13   socklen_t dummy = sizeof sa ;
     14   if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1)
     15   {
     16     char ch ;
     17     fd_read(s, &ch, 1) ;
     18     return 0 ;
     19   }
     20   return 1 ;
     21 }