apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bennett, Tony - CNF" <Bennett.T...@cnf.com>
Subject RE: APR Socket Questions
Date Thu, 30 Sep 2004 01:23:53 GMT

  apr_poll_socket_add() is in an older version of APR.

  My use of apr_poll() using APR 1.0 is limited to only caring
  about a single socket descriptor.
  Here's how I handled it (again on waiting up to 5 seconds for 
  a connect to complete):
            poll_fd.p           = pool;
            poll_fd.desc_type   = APR_POLL_SOCKET;
            poll_fd.reqevents   = APR_POLLOUT;
            poll_fd.rtnevents   = 0;
            poll_fd.desc.s      = *sock;
            poll_fd.client_data = NULL;

             * wait 5 seconds for the connect to complete
            status = apr_poll(&poll_fd, 1, &nbr_connects,
(apr_interval_time_t)(5 * APR_USEC_PER_SEC));
            if ( status != APR_SUCCESS ) 
               stuff deleted

  I haven't done it yet, but if you need to monitor multiple sockets,
  then you could use these:
       apr_pollset_create()  /* creates an apr_pollset_t
       apr_pollset_add()     /* adds an apr_pollfd_t to an apr_pollset_t
	 apr_pollset_remove()  /* removes an apr_pollfd_t from an
apr_pollset_t */
	 apr_pollset_destroy() /* destroys an apr_pollset_t
       apr_pollset_poll()    /* blocks for activity on the descriptors
in the apr_pollset_t */

Regarding use of SOMAXCONN...

How about:
    #ifdef SOMAXCONN
       listen_cnt = SOMAXCONN;
       listen_cnt = 5;  /* or what ever number you want */


-----Original Message-----
From: David Barrett [mailto:dbarrett@quinthar.com] 
Sent: Wednesday, September 29, 2004 4:58 PM
To: dev@apr.apache.org
Subject: RE: APR Socket Questions

> -----Original Message-----
> From: Bennett, Tony - CNF [mailto:Bennett.Tony@cnf.com]
> Subject: RE: APR Socket Questions
> 2) Is "apr_poll( )" the equivalent to "select( )"?  How do I convert 
> an "apr_socket_t" into a "apr_pollfd_t" in order to add to the
> ...
>             apr_poll_socket_add(readbits, sock, APR_POLLOUT); ...

Ah, looks great, thanks!  However, my installation doesn't have
"apr_poll_socket_add( )".  I'm using APR-1.0.0, what version of the API
are you using?

> 7) When setting a socket to listen on a port, how can I choose the 
> maximum backlog?  Normally I'd say "listen( s, SOMAXCONN )".  Should I

> just use "apr_socket_listen( s, SOMAXCONN )", or is there an APR 
> replacement for SOMAXCONN?
> Searching APR doesn't reveal SOMAXCONN being used.

I guess what I'm asking is the right way to do it, not merely what will
work.  I'm leery of mixing APR and socket functions and macros -- I'd
prefer to go all or nothing.  However, if there's no APR equivalent for
SOMAXCONN (like there appears to be no equivalent for SOCK_STREAM), then
I'll use that. 

Thanks!  Can anyone help me with the non-blocking issues?


View raw message