Interface nsITransportType

nsITransport

This interface provides a common way of accessing i/o streams connected to some resource. This interface does not in any way specify the resource. It provides methods to open blocking or non-blocking, buffered or unbuffered streams to the resource. The name "transport" is meant to connote the inherent data transfer implied by this interface (i.e., data is being transfered in some fashion via the streams exposed by this interface).

A transport can have an event sink associated with it. The event sink receives transport-specific events as the transfer is occuring. For a socket transport, these events can include status about the connection. See nsISocketTransport for more info about socket transport specifics.

Hierarchy

Methods

  • Increases the reference count for this interface. The associated instance will not be deleted unless the reference count is returned to zero.

    Returns

    The resulting reference count.

    Returns number

  • Parameters

    • aIID: object
    • Optional aInstancePtr: object

    Returns any

  • A run time mechanism for interface discovery.

    Returns

    NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.

    aInstancePtr must not be null.

    Parameters

    • aIID: object

      [in] A requested interface IID

    • aInstancePtr: object

      [out] A pointer to an interface pointer to receive the result.

    Returns void

  • Decreases the reference count for this interface. Generally, if the reference count returns to zero, the associated instance is deleted.

    Returns

    The resulting reference count.

    Returns number

  • Close the transport and any open streams.

    Parameters

    • aReason: number

      the reason for closing the stream.

    Returns void

  • Open an input stream on this transport.

    Flags have the following meaning:

    OPEN_BLOCKING If specified, then the resulting stream will have blocking stream semantics. This means that if the stream has no data and is not closed, then reading from it will block the calling thread until at least one byte is available or until the stream is closed. If this flag is NOT specified, then the stream has non-blocking stream semantics. This means that if the stream has no data and is not closed, then reading from it returns NS_BASE_STREAM_WOULD_BLOCK. In addition, in non-blocking mode, the stream is guaranteed to support nsIAsyncInputStream. This interface allows the consumer of the stream to be notified when the stream can again be read.

    OPEN_UNBUFFERED If specified, the resulting stream may not support ReadSegments. ReadSegments is only gauranteed to be implemented when this flag is NOT specified.

    Parameters

    • aFlags: number

      optional transport specific flags.

    • aSegmentSize: number

      if OPEN_UNBUFFERED is not set, then this parameter specifies the size of each buffer segment (pass 0 to use default value).

    • aSegmentCount: number

      if OPEN_UNBUFFERED is not set, then this parameter specifies the maximum number of buffer segments (pass 0 to use default value).

    Returns nsIInputStream

  • Open an output stream on this transport.

    Flags have the following meaning:

    OPEN_BLOCKING If specified, then the resulting stream will have blocking stream semantics. This means that if the stream is full and is not closed, then writing to it will block the calling thread until ALL of the data can be written or until the stream is closed. If this flag is NOT specified, then the stream has non-blocking stream semantics. This means that if the stream is full and is not closed, then writing to it returns NS_BASE_STREAM_WOULD_BLOCK. In addition, in non- blocking mode, the stream is guaranteed to support nsIAsyncOutputStream. This interface allows the consumer of the stream to be notified when the stream can again accept more data.

    OPEN_UNBUFFERED If specified, the resulting stream may not support WriteSegments and WriteFrom. WriteSegments and WriteFrom are only guaranteed to be implemented when this flag is NOT specified.

    Parameters

    • aFlags: number

      optional transport specific flags.

    • aSegmentSize: number

      if OPEN_UNBUFFERED is not set, then this parameter specifies the size of each buffer segment (pass 0 to use default value).

    • aSegmentCount: number

      if OPEN_UNBUFFERED is not set, then this parameter specifies the maximum number of buffer segments (pass 0 to use default value).

    Returns nsIOutputStream

  • Set the transport event sink.

    Parameters

    • aSink: nsITransportEventSink

      receives transport layer notifications

    • aEventTarget: nsIEventTarget

      indicates the event target to which the notifications should be delivered. if NULL, then the notifications may occur on any thread.

    Returns void

Generated using TypeDoc