On Wed, 23 Oct 2002, Damir Dezeljin wrote: > I'm looking how to convert an UNIX socket to APR socket (apr_socket_t). > Can anyone help me please? Is there also any way to convert stdin/stdout > to apr_socket_t (I'm trying to use APR to write a simple daemon example, > one for inetd, so I need stdin/stdout, and the other one more general). > Also is there any way to convert file descriptor (int and/or FILE *) to > APR file descriptors?
Well, for int fd's, you can use apr_os_file_put(), or apr_os_pipe_put() if it's a pipe [see apr_portable.h]. I'm not aware of any currently-existing equivalent for sockets, but we might be able to add one. So for stdin, for example: { int fd = 0; /* stdin */ apr_file_t *file; return apr_os_file_put(&file, &fd, 0, pool); } This function, coincidentally, is a routine called apr_file_open_stdin(), which is the more portable way to get an apr_file_t() for stdin (it's implemented differently on windows, for example). Hope this helps, --Cliff