function
Library: TCP/IP client and server support (OMTCP legacy, OmniMark versions 4 - 6.0.1)
Include: omtcp.xin |
Returns: An external output object. |
define external string sink function TCPConnectionGetOutput value TCPConnection this-TCPConnection timeout value integer timeout-in-milliseconds optional protocol value IOProtocol this-IOProtocol optional as TCPConnectionGetOutput
This function returns an external output object, permitting writes on the connection.
If the passed TCP connection object is closed or was never connected, this function returns a dummy external output object that swallows anything written to it. At the same time, it sets the TCP connection object to be in error.
The timeout value applies primarily to data written to the returned external output. In the case of TCPConnectionGetOutput
, the timeout value applies to individual write operations.
TCPConnectionGetOutput
can be called once or more than once (but only if called serially) for a connection. All streams derived from a TCPConnectionGetOutput
write to the same output stream attachment, but may each have their own transformation logic and buffering.
If a TCP connection from which an external output is derived is closed using TCPConnectionClose
, then it is in error to perform a subsequent write to the output. The TCP connection object is set to be in error, and any data written is discarded.
The external output created by TCPConnectionGetOutput
has a name. This name is the same value as that returned by TCPConnectionGetPeerName
for the same TCP connection (that is, the peer name if one is available, or its IP address if not).
In general, for this function, if the time between writing two characters never exceeds the timeout value, no timeout exception occurs. If a timeout exception does occur, the operation involved discards the output text for an output or put and sets the TCPConnection to be in error. If a timeout value is not specified, it writes "block" until data is written, or until some other process indicates that an error has occurred.
Arguments:
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 ("=" ||* 3048 || "%n") ||* 10 put s "hello world" close s repeat exit unless TCPConnectionIsConnected TCP-Conn output TCPConnectionGetCharacters TCP-Conn again