Re: Client socket

2002-05-30 Thread 'Tony Finch'

On Thu, May 30, 2002 at 11:03:05AM +0530, Vinod Panicker wrote:
 
 I need the actual socket that apache uses to communicate with the client
 in the php module.  Is it available somewhere in the request_rec
 structure?

You've already found it in r-connection-client-fd.

Tony.
-- 
f.a.n.finch [EMAIL PROTECTED] http://dotat.at/
SOUTH FITZROY: NORTH OR NORTHEAST 4 OR 5, OCCASIONALLY 6 NEAR CAPE FINISTERRE.
FAIR. GOOD.



RE: Client socket

2002-05-30 Thread Sander Striker

 From: Tony Finch [mailto:[EMAIL PROTECTED]]On Behalf Of 'Tony
 Finch'
 Sent: 30 May 2002 11:01

 On Thu, May 30, 2002 at 11:03:05AM +0530, Vinod Panicker wrote:
  
  I need the actual socket that apache uses to communicate with the client
  in the php module.  Is it available somewhere in the request_rec
  structure?
 
 You've already found it in r-connection-client-fd.

Question: why do you need the socket?  Staying away from the socket
is in general a better idea.  You get all the data through the input
filters, bypassing those means you lose out on a lot of functionality.


Sander



RE: Client socket

2002-05-30 Thread Vinod Panicker

I feel like kicking myself!  Forgot all that I had learnt abt sockets!

What I actually wanted was the ability to use the socket from another
process.  I obviously cant do that in this case since the socket that
has been opened is local to the process (DUH!)

Now I want to pass this socket to another application, which can write
to it when required.  I'm sitting with stevens right now, hunting for
ways in which I can pass open file descriptors to another process :)

Any help would be welcome.

I don't require the input filters, since I want to write to the socket
of a keep-alive connection later.  Was just wondering if I can do it in
a simple way, or I'll have to use libnet to do it

Tx,
Vinod.

---
Vinod Panicker [EMAIL PROTECTED]
Sr. Software Designer
Geodesic Information Systems Ltd. 



-Original Message-
From: Sander Striker [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, May 30, 2002 2:54 PM
To: [EMAIL PROTECTED]; Vinod Panicker
Subject: RE: Client socket


 From: Tony Finch [mailto:[EMAIL PROTECTED]]On Behalf Of 
 'Tony Finch'
 Sent: 30 May 2002 11:01

 On Thu, May 30, 2002 at 11:03:05AM +0530, Vinod Panicker wrote:
  
  I need the actual socket that apache uses to communicate with the 
  client in the php module.  Is it available somewhere in the 
  request_rec structure?
 
 You've already found it in r-connection-client-fd.

Question: why do you need the socket?  Staying away from the socket is
in general a better idea.  You get all the data through the input
filters, bypassing those means you lose out on a lot of functionality.


Sander




Re: Client socket

2002-05-30 Thread Aaron Bannert

On Thu, May 30, 2002 at 03:00:21PM +0530, Vinod Panicker wrote:
 I feel like kicking myself!  Forgot all that I had learnt abt sockets!
 
 What I actually wanted was the ability to use the socket from another
 process.  I obviously cant do that in this case since the socket that
 has been opened is local to the process (DUH!)
 
 Now I want to pass this socket to another application, which can write
 to it when required.  I'm sitting with stevens right now, hunting for
 ways in which I can pass open file descriptors to another process :)
 
 Any help would be welcome.

Unix domain sockets can be used to pass file descriptors, as can
doors and stream pipes (see Advanced Programming in the Unix Environment,
by W. Richard Stevens, Chapter 15, p. 475 for the domain sockets/stream
pipes).

Others and I have been working on adding this functionality to
APR so that it will be available across unix platforms as well as
Windows and others, FWIW.

-aaron



Re: Client socket

2002-05-29 Thread Jeff Trawick

Vinod Panicker [EMAIL PROTECTED] writes:

 Hi,
 
 Where is the client socket fd stored in the request_rec structure?
 
 Is it either of the r-connection-client-fd or the
 r-connection-client-fd_in variables?
 
 I tried accessing the values, but both the variables show the value '3'
 for every request passed to the php module.

Why is 3 incorrect?  Did you do lsof on your httpd process while
stopped in the debugger to verify that 3 is (or is not) the connection
to the client?

Why do you need access to the socket?

-- 
Jeff Trawick | [EMAIL PROTECTED]
Born in Roswell... married an alien...



RE: Client socket

2002-05-29 Thread Vinod Panicker

Hi Jeff,

Thanks for your reply...

Let me explain what exactly I did.

I made changes to the php_apache.c file and added a new php function of
my own, which is supposed to return the client socket when called from a
php script.  Here is the code for the function - 

---

/* {{{ proto int apache_client_socket()
   Get the client socket */
PHP_FUNCTION(apache_client_socket)
{
RETURN_LONG(((request_rec
*)SG(server_context))-connection-client-fd);
}

---

I recompiled php and made a module out of it.  Worked perfectly.  Now, I
wrote a php script with the following code - 

---
?
echo apache_client_socket();
?
---

This script I call from the browser, and everytime it displays a '3'.  I
even called it from different browser windows, still the same.

That cant be alright since if the fd is 3 as shown in one browser
window, it has to be something different in the other window since the
browser defaults to a keep-alive connection, and the fd's have to be
different.

I'll would tell you why I need the socket, but I've described it so many
times that I'm gonna die :(  I'll forward you a mail if you are really
interested.

Tx,
Vinod.

---
Vinod Panicker [EMAIL PROTECTED]
Sr. Software Designer
Geodesic Information Systems Ltd. 



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of Jeff Trawick
Sent: Wednesday, May 29, 2002 4:19 PM
To: [EMAIL PROTECTED]
Subject: Re: Client socket


Vinod Panicker [EMAIL PROTECTED] writes:

 Hi,
 
 Where is the client socket fd stored in the request_rec structure?
 
 Is it either of the r-connection-client-fd or the
 r-connection-client-fd_in variables?
 
 I tried accessing the values, but both the variables show the value 
 '3' for every request passed to the php module.

Why is 3 incorrect?  Did you do lsof on your httpd process while stopped
in the debugger to verify that 3 is (or is not) the connection to the
client?

Why do you need access to the socket?

-- 
Jeff Trawick | [EMAIL PROTECTED]
Born in Roswell... married an alien...




Re: Client socket

2002-05-29 Thread Tony Finch

On Wed, May 29, 2002 at 04:27:59PM +0530, Vinod Panicker wrote:
 
 This script I call from the browser, and everytime it displays a '3'.  I
 even called it from different browser windows, still the same.
 
 That cant be alright since if the fd is 3 as shown in one browser
 window, it has to be something different in the other window since the
 browser defaults to a keep-alive connection, and the fd's have to be
 different.

Each connection is handled in a different process and each process's
fd 3 is different. If a process fork()s two children and each child
accept()s a connection they will each receive a different connection
but it will be allocated the same fd number in each child.

Tony.
-- 
f.a.n.finch [EMAIL PROTECTED] http://dotat.at/
CROMARTY: SOUTHEASTERLY VEERING SOUTHWESTERLY 5 OR 6, DECREASING 4. RAIN THEN
SHOWERS. MODERATE BECOMING GOOD.



RE: Client socket

2002-05-29 Thread Vinod Panicker

Tx a million for your reply.

I need the actual socket that apache uses to communicate with the client
in the php module.  Is it available somewhere in the request_rec
structure?

I've been trying to get this for ages now.

Tx,
Vinod.

---
Vinod Panicker [EMAIL PROTECTED]
Sr. Software Designer
Geodesic Information Systems Ltd. 



-Original Message-
From: Tony Finch [mailto:[EMAIL PROTECTED]] On Behalf Of Tony
Finch
Sent: Wednesday, May 29, 2002 9:33 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: Client socket


On Wed, May 29, 2002 at 04:27:59PM +0530, Vinod Panicker wrote:
 
 This script I call from the browser, and everytime it displays a '3'.

 I even called it from different browser windows, still the same.
 
 That cant be alright since if the fd is 3 as shown in one browser 
 window, it has to be something different in the other window since the

 browser defaults to a keep-alive connection, and the fd's have to be 
 different.

Each connection is handled in a different process and each process's fd
3 is different. If a process fork()s two children and each child
accept()s a connection they will each receive a different connection but
it will be allocated the same fd number in each child.

Tony.
-- 
f.a.n.finch [EMAIL PROTECTED] http://dotat.at/
CROMARTY: SOUTHEASTERLY VEERING SOUTHWESTERLY 5 OR 6, DECREASING 4. RAIN
THEN SHOWERS. MODERATE BECOMING GOOD.