2 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
11 /* Return a pair of socket descriptors that are connected to each other.
12 * The returned descriptors are suitable for use with select(). The two
13 * descriptors may or may not be identical; the function may return
14 * the same descriptor number in both slots. It is guaranteed that
15 * data written on sds[1] will be readable on sds[0]. The returned
16 * descriptors may be datagram oriented, so data should be written
17 * in reasonably small pieces and read all at once. On Unix systems
18 * this function is best implemented using a single pipe() call.
21 int lutil_pair( LBER_SOCKET_T sds[2] )
23 struct sockaddr_in si;
24 int rc, len = sizeof(si);
27 sd = socket( AF_INET, SOCK_DGRAM, 0 );
31 (void) memset( (void*) &si, 0, len );
32 si.sin_family = AF_INET;
34 si.sin_addr.s_addr = htonl( INADDR_LOOPBACK );
36 if ( rc = bind( sd, (struct sockaddr *)&si, len ) ) {
41 if ( rc = getsockname( sd, (struct sockaddr *)&si, &len ) ) {
46 if ( rc = connect( sd, (struct sockaddr *)&si, len ) ) {