You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Tyler MacDonald <ty...@yi.org> on 2007/04/11 20:53:36 UTC

listener from a conn_rec?

Hi,

	Given a connection record, how do I determine what listener
originally accepted the connection? I've dug around the API documentation a
bit and can't find a clear path back to my listener from a connection, but
it would sure be nice to know, for example, what protocol was assigned to a
listener that dispatched my conn_rec...

	TIA,
		Tyler


Re: listener from a conn_rec?

Posted by Tyler MacDonald <ty...@yi.org>.
Here's what I came up with... of course, it falls apart as soon as you have
more than one protocol on the same port (maybe with different bind addresses
or whatever), but doing that is a bad idea anyways, isn't it? :-)

static const char* what_protocol_am_i(conn_rec* c) {
  apr_port_t port = c->local_addr->port;
  ap_listen_rec* cur;
  char* rv;
  char* p;
  int i;
  for(cur = ap_listeners; cur != NULL; cur = cur->next) {
    if(cur->bind_addr->port == port) {
      rv = apr_pstrdup(c->pool, cur->protocol);
      for(p=rv;*p;p++)
        *p = tolower(*p);
      return rv;
    }
  }
  return NULL;
}

This would be *way* simpler if there was just a conn_rec.listener record...

	Cheers,
		Tyler




Tyler MacDonald <ty...@yi.org> wrote:
> Hi,
> 
> 	Given a connection record, how do I determine what listener
> originally accepted the connection? I've dug around the API documentation a
> bit and can't find a clear path back to my listener from a connection, but
> it would sure be nice to know, for example, what protocol was assigned to a
> listener that dispatched my conn_rec...
> 
> 	TIA,
> 		Tyler
> 

-- 

Re: listener from a conn_rec?

Posted by Issac Goldstand <ma...@beamartyr.net>.
While working on some UDP-related issues a while back, I looked into
this a bit.  IIRC, I found that there is no way to do this (and
intentionally so) from the conn_rec.  The socket itself is accessible,
but not in the public API (and possibly not in a platform independent
manner either).

  Issac

Tyler MacDonald wrote:
> Hi,
> 
> 	Given a connection record, how do I determine what listener
> originally accepted the connection? I've dug around the API documentation a
> bit and can't find a clear path back to my listener from a connection, but
> it would sure be nice to know, for example, what protocol was assigned to a
> listener that dispatched my conn_rec...
> 
> 	TIA,
> 		Tyler