[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: LDAP C API: LDAP_OPT_DESC



Kurt D. Zeilenga writes:
> It just occurred to me that the underlying implementation may not
> actually utilize sockets and hence not be able to return the
> underlying I/O descriptor.  It also may be possible for socket
> descriptors to be something different than 'int'.  IIRC, I believe
> it's a pointer under MacOS.
> 
> It might be wise to be generalize or remove LDAP_OPT_DESC.  (I should
> note that some APIs have already introduced a generic "socket" type).
> 
> To generalize LDAP_OPT_DESC, I would suggest adding:
> 	typedef impl_socket_t ber_socket_t;
> 
>    Implementations MUST replace impl_socket_t with an appropriate
>    type.  Implementations returning I/O descriptors SHOULD replace
>    impl_socket_t with a suitable type for I/O descriptors.

You'll have to say something about what the program can _do_ with these
"non-UNIX" descriptors.  With a different socket type, I assume MacOS
socket code looks somewhat different from UNIX socket code -- perhaps
except if one is using a UNIX emulation library?  If they are noticeably
different, maybe it'd be better to have LDAP_OPT_DESC return error and
use a new option for MacOS sockets; I assume a portable application
would need to #ifdef out some UNIX-/MacOS-specific code in any case.
An alternative for the latter would be to #define
LDAP_FEATURE_UNIX_SOCKETS, LDAP_FEATURE_MACOS_SOCKETS and so on.

>    Implementations which do not return I/O descriptors SHOULD replace
>    impl_socket_t with int and MUST always return LDAP_OPT_ERROR.
>    Returning I/O descriptors is RECOMMENDED.

Same here: If the implementation can't return descriptors, the
application will probably want to #ifdef out some socket calls.
So remove LDAP_OPT_DESC or a LDAP_FEATURE_SOCKETS macro.

One final point: If a library wants to support *both* UNIX-like sockets
*and* some other I/O type (e.g. reading and sending the requets to
strings, which the application would read/send by itself), depending on
which option the user sets at startup, we'll need both to #ifdef on
LDAP_FEATURE_* to check if the library/system supports the socket type
in question, and to test the error return from ldap_get_option() to see if
the LDAP* object supports the socket type.

-- 
Hallvard