>
> On Wed, Aug 21, 2002 at 01:48:08AM +0800, C K Tan wrote:
> > Hi, I am looking for a way to check if a socket is still connected to
> > the client.
> > What is a good way to do this in APR? Here are some tries which do not
> > work
> > (on Win32 with the cvs co latest):
>
> Use apr_poll and look for the out of band errors.
>
> flood uses the following to check the socket:
>
> apr_status_t check_socket(flood_socket_t *s, apr_pool_t *pool)
> {
> apr_status_t e;
> apr_int32_t socketsRead;
> apr_pollfd_t pout;
> apr_int16_t event;
>
> pout.desc_type = APR_POLL_SOCKET;
> pout.desc.s = s->socket;
> pout.reqevents = APR_POLLIN | APR_POLLPRI | APR_POLLERR |
> APR_POLLHUP | APR_POLLNVAL;
> pout.p = pool;
>
> e = apr_poll(&pout, 1, &socketsRead, 1000);
> if (socketsRead && pout.rtnevents) {
> return APR_EGENERAL;
> }
>
> return APR_SUCCESS;
> }
>
> Note that flood checks for POLLIN because it is a client and shouldn't
> see anything incoming that it hasn't requested, so that would be an
> error.
>
> HTH. -- justin
>
So if poll returns -1, this function will return APR_SUCCESS? That doesn't
seem right.
Bill