![]() Chapter Contents  | 
![]() Previous  | 
![]() Next  | 
| getclientid | 
| Portability: | SAS/C extension | 
| SYNOPSIS | |
| DESCRIPTION | |
| RETURN VALUE | |
| CAUTIONS | |
| PORTABILITY | |
| EXAMPLE | |
| RELATED FUNCTIONS | 
| SYNOPSIS | 
#include <sys/types.h> #include <sys/socket.h> int getclientid(int domain, struct clientid *clientid);
| DESCRIPTION | 
getclientid
 gets the identifier of the calling application. 
domain
 is 
AF_INET
. 
clientid
is a pointer to the 
clientid
structure, which is filled on return from the call.  
getclientid
 is used in the 
givesocket
 and 
takesocket
 calls, which enable cooperative processes to pass socket
descriptors to each other.
Note:   
getclientid
 is only supported with non-integrated
sockets. However, starting with SAS/C Release 7.00, the getclientid function
is supported for integrated sockets.  ![[cautionend]](../common/images/cautend.gif)
| RETURN VALUE | 
If 
getclientid
 succeeds, it returns a 
0
.   Otherwise, it returns a 
-1
 and sets 
errno
to indicate the type of error.
| CAUTIONS | 
| PORTABILITY | 
getclientid
 is not portable to UNIX operating systems. On a UNIX operating
system, sockets can be transferred from parent to child processes when the
child process has been created via the 
fork
 system call.
| EXAMPLE | 
In this example, 
getclientid
 returns the client ID from TCP/IP.
  
#include <stddef.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
   /* These three application routines implement communication  */
   /* between the parent task and this task. They use a means   */
   /* other than sockets to communicate.                        */
fromparent(void *, size_t);
toparent(void *, size_t);
postparent(void);
   /* This routine receives a socket from its parent            */
   /* task and store the descriptor into the integer pointed    */
   /* to by "s".                                                */
recvsock(int *s)
{
   struct clientid id;
      /* Get the clientid from TCP/IP.                          */
   if (getclientid (AF_INET, &id)==-1) {
      perror ("Can't get client ID");
      return -1;
   }
      /* Pass clientid to parent.                               */
   toparent(&id,sizeof(id));
      /* Get socket descriptor number from parent.              */
   fromparent(s, sizeof(*s));
      /* Take socket from parent.                               */
   if (takesocket(&id, *s)==-1) {
      perror ("takesocket failed");
      return -1;
   }
      /* Tell parent that takesocket is completed.              */
   postparent();
   return 0;
}
| RELATED FUNCTIONS | 
getclientpid, 
givesocket
, givesocket_pid, 
takesocket
,
takesocket_pid
![]() Chapter Contents  | 
![]() Previous  | 
![]() Next  | 
![]() Top of Page  | 
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.