TCPConnectionGetSource
Full Description
swirl
Syntax
  define external source function TCPConnectionGetSource
        value TCPConnection this-TCPConnection
        timeout value counter timeout-in-milliseconds optional
        protocol value IOProtocol this-IOProtocol optional
  as TCPConnectionGetSource


Purpose

This function returns an external source object from which data will be read.

If the passed TCP connection object is closed or was never connected, then this function returns a dummy external source object that immediately returns "end of input". At the same time, it sets the TCP connection object to be in error.

The timeout value applies primarily to data read from the returned external source.

TCPConnectionGetSource can be called more than once for a connection. All such derived sources read from the same source attachment, but such sources are subject to read-ahead, and it is generally the case that a read from a source will actually capture more data than is needed for immediate use. This means that if there are two or more sources derived from a connection, it is usually the case that data read from one such source is not that which immediately follows that read from another such source. As a consequence, only ONE external source can be derived from a connection at a time. That is, sources must be derived serially.

If a TCP connection from which an external source is derived is closed using TCPConnectionClose, then it is in error to perform a read from the source. The TCP connection object is made to be in error, and the source returns "end of input", as it does for other errors.

Arguments:

  • "this-TCPConnection" is an opaque object of type TCPConnection.
  • "timeout-in-milliseconds" is a counter value which indicates the number of milliseconds the connection will wait before terminating.
  • "this-IOProtocol" is an optional argument specifying which IO protocol is to be used.

Example:

  local TCPConnection TCP-Conn
  local stream s

  set TCP-Conn to TCPConnectionOpen on "localhost" at 5300
  TCPConnectionSetBuffering TCP-Conn enabled false

  open s with binary-mode as
     TCPConnectionGetOutput TCP-Conn
        protocol IOProtocolMultiPacket

  put s "hello world"
  close s

  output TCPConnectionGetSource TCP-Conn
        protocol IOProtocolMultiPacket

Copyright © OmniMark Technologies Corporation, 1988-1998.