Class | Qpid::Proton::Transport |
In: |
lib/core/transport.rb
|
Parent: | Object |
A transport is used by a connection to interface with the network.
A transport is associated with, at most, one Connection.
Initially, a transport is configured to be a client tranpsort. It can be configured to act as a server when it is created.
A client transport initiates outgoing connections.
A client transport must be configured with the protocol layers to use and cannot configure itself automatically.
A server transport accepts incoming connections. It can automatically configure itself to include the various protocol layers depending on the incoming protocol headers.
Data can be traced into and out of the transport programmatically by setting the trace level to one of the defined trace values (TRACE_RAW, TRACE_FRM or TRACE_DRV). Tracing can also be turned off programmatically by setting the trace level to TRACE_OFF.
@example
# turns on frame tracing @transport.trace = Qpid::Proton::Transport::TRACE_FRM # ... do something where the frames are of interest, such as debugging # turn tracing off again @transport.trace = Qpid::Proton::Transport::TRACE_NONE
Tracing can also be enabled from the command line by defining the similarly named environment variable before starting a Proton application:
@example
# enable tracing from the command line PN_TRACE_FRM=1 ruby my_proton_app.rb
TRACE_OFF | = | Cproton::PN_TRACE_OFF | Turn logging off entirely. | |
TRACE_RAW | = | Cproton::PN_TRACE_RAW | Log raw binary data into/out of the transport. | |
TRACE_FRM | = | Cproton::PN_TRACE_FRM | Log frames into/out of the transport. | |
TRACE_DRV | = | Cproton::PN_TRACE_DRV | Log driver related events; i.e., initialization, end of stream, etc. | |
CLIENT | = | 1 | @private | |
SERVER | = | 2 | @private | |
PROTON_METHOD_PREFIX | = | "pn_transport" | @private |
Creates a new transport instance.
@param mode [Fixnum] The transport mode, either CLIENT or SERVER @param impl [pn_transport_t] Should not be used.
@raise [TransportError] If the mode is invalid.
Indicate that the output has closed.
Tells the transport that no more output will be popped.
@raise [TransportError] If an error occurs.
Indicate that the input has reached EOS (end of stream).
This tells the transport that no more input will be forthcoming.
@raise [TransportError] If an error occurs.
Return the AMQP connection associated with the transport.
@return [Connection, nil] The bound connection, or nil.
Log a message to the transport‘s logging mechanism.
This can be using in a debugging scenario as the message will be prepended with the transport‘s identifier.
@param message [String] The message to be logged.
Returns the specified number of bytes from the transport‘s buffers.
@param size [Fixnum] The number of bytes to return.
@return [String] The data peeked.
@raise [TransportError] If an error occurs.
Removes the specified number of bytes from the pending output queue following the transport‘s head pointer.
@param size [Fixnum] The number of bytes to remove.
Process input data following the tail pointer.
Calling this function will cause the transport to consume the specified number of bytes of input occupying the free space following the tail pointer. It may also change the value for tail, as well as the amount of free space reported by capacity.
@param size [Fixnum] The number of bytes to process.
@raise [TransportError] If an error occurs.
Pushes the supplied bytes into the tail of the transport.
@param data [String] The bytes to be pushed.
@return [Fixnum] The number of bytes pushed.
Returns whether the transport has any buffered data.
@return [Boolean] True if the transport has no buffered data.
Process any pending transport timer events.
This method should be called after all pending input has been processed by the transport (see input), and before generating output (see output).
It returns the deadline for the next pending timer event, if any art present.
@param now [Time] The timestamp.
@return [Fixnum] If non-zero, the expiration time of the next pending
timer event for the transport. The caller must invoke #tick again at least once at or before this deadline occurs.