Chapter Contents

Previous

Next
givesocket

givesocket



Gives a Socket to Another Process

Portability: SAS/C extension


SYNOPSIS
DESCRIPTION
RETURN VALUE
PORTABILITY
RELATED FUNCTIONS


SYNOPSIS

#include <sys/types.h>
#include <sys/socket.h>

int givesocket(int s, const struct clientid * clientid);


DESCRIPTION

givesocket specifies that socket s is available to another process. s must be a connected stream socket. After a successful givesocket call, the donor process, which is often a concurrent server, passes its client ID clientid and the socket descriptor for s to the receiving process. The donor process must have already obtained the client ID of the receiving process.

To pass a socket, the donor program calls givesocket with the clientid structure filled in as follows:

Field Description
domain AF_INET
name Receiving program's address space name, left justified and padded with blanks
subtaskname blanks
reserved binary zones

The receiving process then completes the operation by issuing a takesocket call. The mechanism for exchanging client IDs and socket descriptor values is the responsibility of the two processes and is not accomplished by either the givesocket or the takesocket call.

If givesocket is successful, s is not available for any other calls until a close is issued for s . Do not issue a close call until the other application has successfully completed a takesocket call for s ; otherwise the connection is reset.

The select or selectecb functions can be used to wait on an exception condition for a given socket. An exception condition is raised on a socket when the receiver has taken the socket with the socket function. When the exception is raised, the donor program can close the socket.

Note:    givesocket is only supported with non-integrated sockets.  [cautionend]


RETURN VALUE

If givesocket succeeds, it returns a 0 . Otherwise, it returns a -1 , and sets errno to indicate the type of error.


PORTABILITY

givesocket is not portable to UNIX operating systems. On UNIX operating systems, sockets are typically transferred from parent to child processes as a side effect of the fork system call.


RELATED FUNCTIONS

getclientid , select , selectecb , takesocket


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.