Chapter Contents |
Previous |
Next |
takesocket |
Portability: | SAS/C extension |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
CAUTIONS | |
PORTABILITY | |
EXAMPLE | |
RELATED FUNCTIONS |
SYNOPSIS |
#include <sys/types.h> #include <sys/socket.h> int takesocket(struct clientid *clientid, int s);
DESCRIPTION |
takesocket
takes a socket descriptor,
s
, and a pointer to a client structure,
clientid
, and returns a local client socket descriptor, which must
be used for subsequent TCP/IP calls.
s
must be a connected stream socket. The donor process must have already
obtained client ID for the receiving process, and must have already called
givesocket
. The mechanism for
exchanging client IDs and the socket descriptor number is the responsibility
of the two processes and is not accomplished by either the
givesocket
or the
takesocket
call.
When giving a socket, the donor may use a
clientid
structure that contains blanks as the
subtask name. However, when taking a socket, the receiver must specify the
subtask name of the donor in the client ID. This allows the donor to make
the socket available to any number of subtasks while the receiver must have
the actual subtask name to take the socket. The subtask name effectively acts
as a key.
The donor process should not close the socket before
the receiving process has completed the
takesocket
call. The receiving process must have a means of informing
the donor that the
takesocket
call has completed. Using
select
or
selectecb
in the donor, frees the receiver of this responsiblility.
Note:
takesocket
is only supported
with non-integrated sockets. However, starting with SAS/C Release 7.00, the
takesocket
function is supported
for integrated sockets.
RETURN VALUE |
If
takesocket
is successful, it returns a non-negative, client socket
descriptor, which can be different from the donor descriptor,
s
. Otherwise, it returns a
-1
, and sets
errno
to indicate the type of error.
CAUTIONS |
PORTABILITY |
takesocket
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.
EXAMPLE |
Refer to the
getclientid
function for an example that illustrates the use of
takesocket
.
RELATED FUNCTIONS |
getclientid
, getclientpid
,
givesocket
, givesocket_pid
,
takesocket_pid
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.