# Passenger::StandardSession Class Reference

A "standard" implementation of Session. More...

`#include <Session.h>`

Inheritance diagram for Passenger::StandardSession:
[legend]

List of all members.

## Public Member Functions

virtual void | initiate ()
| Initiate the session by connecting to the associated process.
virtual bool | initiated () const
| Returns whether this session has been initiated (that is, whether initiate() had been called in the past).
virtual string | getSocketType () const
| Returns the type of the socket that this session is served from, e.g.
virtual string | getSocketName () const
| Returns the address of the socket that this session is served from.
virtual int | getStream () const
| Returns this session's channel's file descriptor.
virtual void | setReaderTimeout (unsigned int msec)
| Set the timeout value for reading data from the I/O channel.
virtual void | setWriterTimeout (unsigned int msec)
| Set the timeout value for writing data from the I/O channel.
virtual void | shutdownReader ()
| Indicate that we don't want to read data anymore from the I/O channel.
virtual void | shutdownWriter ()
| Indicate that we don't want to write data anymore to the I/O channel.
virtual void | closeStream ()
| Close the I/O stream.
virtual void | discardStream ()
| Discard the I/O channel's file descriptor, so that the destructor won't automatically close it.
virtual pid_t | getPid () const
| Get the process ID of the application process that this session belongs to.

## Protected Attributes

int | fd
| The session connection file descriptor.

## Detailed Description

A "standard" implementation of Session.

## Member Function Documentation

virtual void Passenger::StandardSession::closeStream | ( |  | ) | `[inline, virtual]`

Close the I/O stream.

Exceptions:

  | SystemException | Something went wrong.
  | boost::thread_interrupted |

Precondition:
  initiated()

Postcondition:
  getStream() == -1

Implements Passenger::Session.

virtual void Passenger::StandardSession::discardStream | ( |  | ) | `[inline, virtual]`

Discard the I/O channel's file descriptor, so that the destructor won't automatically close it.

Precondition:
  initiated()

Postcondition:
  getStream() == -1

Implements Passenger::Session.

virtual string Passenger::StandardSession::getSocketName | ( |  | ) | const`[inline, virtual]`

Returns the address of the socket that this session is served from.

This can be a Unix socket filename or a TCP host:port string like "127.0.0.1:1234".

Postcondition:
  !result.empty()

Implements Passenger::Session.

virtual string Passenger::StandardSession::getSocketType | ( |  | ) | const`[inline, virtual]`

Returns the type of the socket that this session is served from, e.g.

"unix" indicating a Unix socket.

Postcondition:
  !result.empty()

Implements Passenger::Session.

virtual int Passenger::StandardSession::getStream | ( |  | ) | const`[inline, virtual]`

Returns this session's channel's file descriptor.

This stream is full-duplex, and will be automatically closed upon Session's destruction, unless discardStream() is called.

Precondition:
  initiated()

Returns:
  The file descriptor, or -1 if the I/O channel has already been closed or discarded.

Implements Passenger::Session.

virtual void Passenger::StandardSession::initiate | ( |  | ) | `[inline, virtual]`

Initiate the session by connecting to the associated process.

A Session is not usable until it's initiated.

Exceptions:

  | SystemException | Something went wrong.
  | IOException | Something went wrong.
  | boost::thread_interrupted |

Implements Passenger::Session.

virtual void Passenger::StandardSession::setReaderTimeout | ( | unsigned int | msec | ) | `[inline, virtual]`

Set the timeout value for reading data from the I/O channel.

If no data can be read within the timeout period, then the read call will fail with error EAGAIN or EWOULDBLOCK.

Precondition:
  The I/O channel hasn't been closed or discarded.
  initiated()

Parameters:

  | msec | The timeout, in milliseconds. If 0 is given, there will be no timeout.

Exceptions:

  | SystemException | Cannot set the timeout.

Implements Passenger::Session.

virtual void Passenger::StandardSession::setWriterTimeout | ( | unsigned int | msec | ) | `[inline, virtual]`

Set the timeout value for writing data from the I/O channel.

If no data can be written within the timeout period, then the write call will fail with error EAGAIN or EWOULDBLOCK.

Precondition:
  The I/O channel hasn't been closed or discarded.
  initiated()

Parameters:

  | msec | The timeout, in milliseconds. If 0 is given, there will be no timeout.

Exceptions:

  | SystemException | Cannot set the timeout.

Implements Passenger::Session.

virtual void Passenger::StandardSession::shutdownReader | ( |  | ) | `[inline, virtual]`

Indicate that we don't want to read data anymore from the I/O channel.

Calling this method after closeStream()/discardStream() is called will have no effect.

Precondition:
  initiated()

Exceptions:

  | SystemException | Something went wrong.
  | boost::thread_interrupted |

Implements Passenger::Session.

virtual void Passenger::StandardSession::shutdownWriter | ( |  | ) | `[inline, virtual]`

Indicate that we don't want to write data anymore to the I/O channel.

Calling this method after closeStream()/discardStream() is called will have no effect.

Precondition:
  initiated()

Exceptions:

  | SystemException | Something went wrong.
  | boost::thread_interrupted |

Implements Passenger::Session.

## Member Data Documentation

int Passenger::StandardSession::fd `[protected]`

The session connection file descriptor.

The documentation for this class was generated from the following file:

- Session.h