|
||||||||||
|
|
||||||||||
| Related Syntax | Other Library Functions | |||||||||
| function | tcp-source |
Available in:
Professional Enterprise |
|
Library: omtcp - TCP/IP client and server support
Include: omtcp.xin |
Return type: schema Returns: |
define external source function tcp-source
value tcp-connection Connection
timeout value integer ms optional
protocol value IOProtocol Protocol optional
where
Use tcp-source to obtain an external source object from which data will be read.
You must include the following line at the beginning of your OmniMark program:
include "omtcp.xin"
Connection must exist (else external exception TCP05).
There may not be an active external source derived from Connection with tcp-source (else external exception TCP04).
If the received packet is corrupted, external exception TCP13 is thrown.
The timeout value applies primarily to data read from the returned external source. If a read operation times out, external exception TCP07 is thrown.
tcp-source 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.
local tcp-connection Connection-1
local stream s
set Connection-1 to tcp-connect on "localhost" at 5300
tcp-set-buffering Connection-1 enabled false
open s with binary-mode as
tcp-get Connection-1
protocol IOProtocolMultiPacket
put s "hello world"
close s
output tcp-source Connection-1
protocol IOProtocolMultiPacket
| ---- |