You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by zethix or something <ze...@mtel.net> on 2001/09/18 15:22:27 UTC

open persistent client connection from apache 2?

Hi,

I'm writing a module for apache 2. What I need is to create a socket from
the server, then connect it to somewhere and keep the connection open
while the server is alive. Also, of course, I would like to be able to
receive data from the socket and then to trigger handling of a request by
the rest of the server code. Is this possible? 

regards zethix



Re: open persistent client connection from apache 2?

Posted by Ryan Bloom <rb...@covalent.net>.
Not really.  There are no current modules that implement a persistent
connection and use that to serve requests.  mod_pop3 and mod_ssl
use the listen directive to open different sockets, but the core closes
those sockets automatically, because they are registered with the
ptrans pool.  Even if they weren't closed, it wouldn't work, because
the MPM wouldn't know to include those sockets in the poll() call.

Ryan

On Tuesday 18 September 2001 09:13 am, Ian Holsman wrote:
> doesn't mod-pop3/mod_ssl do something similiar to this?
>
> they listen on different ports and the standard '80'
> you might be able to do something similiar to this.
> but you need some method of not 'ending' the connection'
>
> On Tue, 2001-09-18 at 07:05, Ryan Bloom wrote:
> > On Tuesday 18 September 2001 06:22 am, zethix or something wrote:
> >
> > This is possible, but not easy.  You will need to write your own MPM,
> > so that you can detect when there is data on that socket.  Of course,
> > you could also just modify one of the existing MPMs, but this kind
> > of logic is unlikely to ever get into the core.
> >
> > Or, you could hack a module together to do this.  Two ways I can think
> > of:
> >
> > 1)  In the post_config phase, fork a process that will open a socket, and
> > listen on it.
> > 2)  In the post_config phase create a thread to open a socket and listen
> > on it.  (Creating a thread in the parent process would be a bad thing
> > IMO, so I like option 1 better).
> >
> > That process/thread will listen on the socket, and when data come in,
> > it will connect to the server, and make a request.  The data will go back
> > to your process, and you will forward it back out through that process.
> >
> > Of course, this has scalability issues, because there is only one request
> > at a time, but that can be gotten around by forking, the way mod_cgid
> > does, or by making that process multi-threaded.
> >
> > Ryan
> >
> > > Hi,
> > >
> > > I'm writing a module for apache 2. What I need is to create a socket
> > > from the server, then connect it to somewhere and keep the connection
> > > open while the server is alive. Also, of course, I would like to be
> > > able to receive data from the socket and then to trigger handling of a
> > > request by the rest of the server code. Is this possible?
> > >
> > > regards zethix
> >
> > --
> >
> > ______________________________________________________________
> > Ryan Bloom				rbb@apache.org
> > Covalent Technologies			rbb@covalent.net
> > --------------------------------------------------------------

-- 

______________________________________________________________
Ryan Bloom				rbb@apache.org
Covalent Technologies			rbb@covalent.net
--------------------------------------------------------------

Re: open persistent client connection from apache 2?

Posted by Ian Holsman <ia...@cnet.com>.
doesn't mod-pop3/mod_ssl do something similiar to this?

they listen on different ports and the standard '80'
you might be able to do something similiar to this.
but you need some method of not 'ending' the connection'

On Tue, 2001-09-18 at 07:05, Ryan Bloom wrote:
> On Tuesday 18 September 2001 06:22 am, zethix or something wrote:
> 
> This is possible, but not easy.  You will need to write your own MPM,
> so that you can detect when there is data on that socket.  Of course,
> you could also just modify one of the existing MPMs, but this kind
> of logic is unlikely to ever get into the core.
> 
> Or, you could hack a module together to do this.  Two ways I can think
> of:
> 
> 1)  In the post_config phase, fork a process that will open a socket, and
> listen on it.
> 2)  In the post_config phase create a thread to open a socket and listen
> on it.  (Creating a thread in the parent process would be a bad thing IMO,
> so I like option 1 better).
> 
> That process/thread will listen on the socket, and when data come in,
> it will connect to the server, and make a request.  The data will go back to
> your process, and you will forward it back out through that process.
> 
> Of course, this has scalability issues, because there is only one request
> at a time, but that can be gotten around by forking, the way mod_cgid does,
> or by making that process multi-threaded.
> 
> Ryan
> 
> > Hi,
> >
> > I'm writing a module for apache 2. What I need is to create a socket from
> > the server, then connect it to somewhere and keep the connection open
> > while the server is alive. Also, of course, I would like to be able to
> > receive data from the socket and then to trigger handling of a request by
> > the rest of the server code. Is this possible?
> >
> > regards zethix
> 
> -- 
> 
> ______________________________________________________________
> Ryan Bloom				rbb@apache.org
> Covalent Technologies			rbb@covalent.net
> --------------------------------------------------------------
-- 
Ian Holsman          IanH@cnet.com
Performance Measurement & Analysis
CNET Networks   -   (415) 364-8608


Re: open persistent client connection from apache 2?

Posted by Ryan Bloom <rb...@covalent.net>.
On Tuesday 18 September 2001 06:22 am, zethix or something wrote:

This is possible, but not easy.  You will need to write your own MPM,
so that you can detect when there is data on that socket.  Of course,
you could also just modify one of the existing MPMs, but this kind
of logic is unlikely to ever get into the core.

Or, you could hack a module together to do this.  Two ways I can think
of:

1)  In the post_config phase, fork a process that will open a socket, and
listen on it.
2)  In the post_config phase create a thread to open a socket and listen
on it.  (Creating a thread in the parent process would be a bad thing IMO,
so I like option 1 better).

That process/thread will listen on the socket, and when data come in,
it will connect to the server, and make a request.  The data will go back to
your process, and you will forward it back out through that process.

Of course, this has scalability issues, because there is only one request
at a time, but that can be gotten around by forking, the way mod_cgid does,
or by making that process multi-threaded.

Ryan

> Hi,
>
> I'm writing a module for apache 2. What I need is to create a socket from
> the server, then connect it to somewhere and keep the connection open
> while the server is alive. Also, of course, I would like to be able to
> receive data from the socket and then to trigger handling of a request by
> the rest of the server code. Is this possible?
>
> regards zethix

-- 

______________________________________________________________
Ryan Bloom				rbb@apache.org
Covalent Technologies			rbb@covalent.net
--------------------------------------------------------------