conn_rec API

Every incoming request to Apache has an associated conn_rec object which contains information about the connection. This object can also be used to directly read and write to the remote client.

base_server

Synopsis

conn_rec.base_server

Description

This attribute is a reference to a server_rec object on which the connection came in.

local_addr

Synopsis

conn_rec.local_addr

Description

This string attribute contains the local address that the request came in on. Example: 127.0.0.1

remote_addr

Synopsis

conn_rec.remote_addr

Description

This string attribute contains the remote address of the incoming connection. Example: 69.0.0.1

write

Synopsis

conn_rec.write( the_skinny)

Arguments

Return Value

Returns a tuple (status, nbytes), where status is one of the APR error codes in the mod_snake module, and nbytes are the number of bytes successfully written.

Description

Occasionally a module writer may wish to write directly to the remote connection, such as when using a protocol other than HTTP. This routine allows the module to communicate directly with the remote client.

read

Synopsis

conn_rec.read( nbytes)

Arguments

Return Value

Returns a tuple (status, nbytes, data) where status is one of the APR error codes in the mod_snake module, nbytes is the number of bytes read, and data is the actual data read from the client.

Description

This method allows modules to read data from the remote client.

flush

Synopsis

conn_rec.flush

Description

This method flushes the buffered output, as sent from conn_rec.write()

remote_ip

Synopsis

conn_rec.remote_ip

Description

This string attribute contains the remote IP address of the incoming connection. Example: 127.0.0.1

keepalive

Synopsis

conn_rec.keepalive

Description

This integer attribute indicates whether or not HTTP keep-alive is in effect for the current connection. -1 indiciates a fatal error, 0 undecided, and 1 yes.

keptalive

Synopsis

conn_rec.keptalive

Description

This true/false attribute indicates whether or not HTTP keep-alive was used during the request.

double_reverse

Synopsis

conn_rec.double_reverse

Description

This integer attribute indicates whether or not double-reverse DNS has been performed. -1 = failure, 0 = not yet, 1 = yes

keepalives

Synopsis

conn_rec.keepalives

Description

This integer attribute indicates how many times this connection has been used for requests.

local_ip

Synopsis

conn_rec.local_ip

Description

This string attribute contains the IP of the server that the connection came in on.

local_host

Synopsis

conn_rec.local_host

Description

This string attribute contains the hostname of the server that the connection came in on.

id

Synopsis

conn_rec.id

Description

This integer attribute contains a unique ID at any given time.