HTTP::Daemon::Threaded::Socket

SUMMARY: CONSTR | METHOD | DETAIL: CONSTR | METHOD

## Class HTTP::Daemon::Threaded::Socket

Inherits from:
  HTTP::Daemon::ClientConn

Enhances HTTP::Daemon::ClientConn with the ability to directly invoke a object-specific event handler for the I/O handle whenever a HTTP::Daemon::Threaded::IOSelector object detects an event on the handle. Also provides interfaces to manage the handle's assignment to the read, write, and exception selectors within the HTTP::Daemon::Threaded::IOSelector object, as well as managing the removal from the selectors when the I/O handle is closed.

Copyright© 2006, Dean Arnold, Presicient Corp., USA
All rights reserved.

Licensed under the Academic Free License version 2.1, as specified in the License.txt file included in this software package, or at OpenSource.org.

Author:
  D. Arnold
Version:
  0.90
Since:
  2005-12-01

Unless otherwise noted, `$self` is the object instance variable.

Method Summary
`addAll()` Add ourself to all the selector's selectors
`addExcept()` Add ourself to the selector's exception selector
`addNoWrite()` Add ourself to the selector's read and exception selectors
`addRead()` Add ourself to the selector's read selector
`addWrite()` Add ourself to the selector's write selector
`close()` Close the socket
`daemon()` Return parent WebClient object
`getContext()` Returns the current context object
`getSelector()` Return the current selector
`get_request($only_headers)` Get client request
`handleSocketEvent($eventmask)` Handle an event on the socket
`removeAll()` Remove ourself from all the selector's selectors
`removeContext()` Remove the context object
`removeExcept()` Remove ourself from the selector's exception selector
`removeNoWrite()` Remove ourself from the selector's read and exception selectors
`removeRead()` Remove ourself from the selector's read selector
`removeSelector()` Remove selector object
`removeWrite()` Remove ourself from the selector's write selector
`send_error($status, $errormsg)` Return error response to a request
`send_file_header()` Return response to a HEAD request for a file
`send_file_response()` Return response to a GET or POST request for a file
`send_redirect($loc, $status, $content)` Return redirect response to a request
`send_response()` Return response to a GET or POST request
`setContext($context, $getpeer)` Set the context object
`setSelector($selector)` Set the HTTP::Daemon::Threaded::IOSelector object

Method Details

### addAll

    addAll()

  Add ourself to all the selector's selectors

  Returns:
    HTTP::Daemon::Threaded::IOSelector object

### addExcept

    addExcept()

  Add ourself to the selector's exception selector

  Returns:
    HTTP::Daemon::Threaded::IOSelector object

### addNoWrite

    addNoWrite()

  Add ourself to the selector's read and exception selectors

  Returns:
    HTTP::Daemon::Threaded::IOSelector object

### addRead

    addRead()

  Add ourself to the selector's read selector

  Returns:
    HTTP::Daemon::Threaded::IOSelector object

### addWrite

    addWrite()

  Add ourself to the selector's write selector

  Returns:
    HTTP::Daemon::Threaded::IOSelector object

### close

    close()

  Close the socket. Removes the socket from the registered HTTP::Daemon::Threaded::IOSelector, closes the handle, and deletes any registered context and selector objects.

  Returns:
    1

### daemon

    daemon()

  Return parent WebClient object. Overrides HTTP::Daemon::ClientConn::daemon to return

  Returns:
    parent HTTP::Daemon::Threaded::WebClient object

### getContext

    getContext()

  Returns the current context object.

  Returns:
    an object

### getSelector

    getSelector()

  Return the current selector.

  Returns:
    HTTP::Daemon::Threaded::IOSelector object

### get_request

    get_request($only_headers)

  Get client request. Overrides HTTP::Daemon::ClientConn::get_request(). Automatically extract weblog entry fragments if a WebLogger is configured.

  Parameters:
    `$only_headers` - boolean; true => only retrieve HTTP headers
  Returns:
    HTTP::Request object

### handleSocketEvent

    handleSocketEvent($eventmask)

  Handle an event on the socket. Invokes the handleSocketEvent() method on any registered context object.

  Parameters:
    `$eventmask` - bitmask indicating read, write, or exception event
  Returns:
    the context object

### removeAll

    removeAll()

  Remove ourself from all the selector's selectors

  Returns:
    HTTP::Daemon::Threaded::IOSelector object

### removeContext

    removeContext()

  Remove the context object.

  Returns:
    HTTP::Daemon::Threaded::Socket object

### removeExcept

    removeExcept()

  Remove ourself from the selector's exception selector

  Returns:
    HTTP::Daemon::Threaded::IOSelector object

### removeNoWrite

    removeNoWrite()

  Remove ourself from the selector's read and exception selectors

  Returns:
    HTTP::Daemon::Threaded::IOSelector object

### removeRead

    removeRead()

  Remove ourself from the selector's read selector

  Returns:
    HTTP::Daemon::Threaded::IOSelector object

### removeSelector

    removeSelector()

  Remove selector object.

  Returns:
    HTTP::Daemon::Threaded::Socket object

### removeWrite

    removeWrite()

  Remove ourself from the selector's write selector

  Returns:
    HTTP::Daemon::Threaded::IOSelector object

### send_error

    send_error($status, $errormsg)

  Return error response to a request. Overrides HTTP::Daemon::ClientConn::send_error(). Automatically writes weblog entry if a WebLogger is configured.

  Parameters:
    `$status` - (optional) HTTP status code of the error; default 400.
    `$errormsg` - (optional) Error message text to be included body of response.
  Returns:
    HTTP status of the response

### send_file_header

    send_file_header()

  Return response to a HEAD request for a file. Borrowed from HTTP::Daemon::ClientConn::send_file_response(), but with content omitted. Automatically write weblog entry if a WebLogger is configured. @params $file path of file to be returned

  Returns:
    HTTP status of the response

### send_file_response

    send_file_response()

  Return response to a GET or POST request for a file. Overrides HTTP::Daemon::ClientConn::send_file_response(). Automatically write weblog entry if a WebLogger is configured. @params $file path of file to be returned

  Returns:
    HTTP status of the response

### send_redirect

    send_redirect($loc, $status, $content)

  Return redirect response to a request. Overrides HTTP::Daemon::ClientConn::send_redirect(). Automatically writes weblog entry if a WebLogger is configured.

  Parameters:
    `$loc` - URL of new target location
    `$status` - (optional) redirect status code (default 301).
    `$content` - (optional) Any alternate content to be returned to client.
  Returns:
    HTTP status of the response

### send_response

    send_response()

  Return response to a GET or POST request. Overrides HTTP::Daemon::ClientConn::send_response(). Automatically writes weblog entry if a WebLogger is configured. @params $res HTTP::Response object to generate response; alternately, may be simple raw content, from which an HTTP::Response object will be generated.

  Returns:
    HTTP status of the response

### setContext

    setContext($context, $getpeer)

  Set the context object. The registered object should implement a handleSocketEvent() method. Also gets a printable peer IP address

  Parameters:
    `$context` - the registered object
    `$getpeer` - boolean; true means get printable peer address
  Returns:
    HTTP::Daemon::Threaded::Socket object

### setSelector

    setSelector($selector)

  Set the HTTP::Daemon::Threaded::IOSelector object.

  Parameters:
    `$selector` - the HTTP::Daemon::Threaded::IOSelector object
  Returns:
    HTTP::Daemon::Threaded::Socket object

Generated by psichedoc on Mon Aug 28 09:45:39 2006