| 
||||||||||
| 
 | 
||||||||||
| Related Syntax | Other Library Functions | |||||||||
| function | tcp-sink | 
  Available in:
   Professional Enterprise  | 
| 
Library: omtcp - TCP/IP client and server support
 Include: omtcp.xin  | 
Return type: String Returns:  | 
  define external output function tcp-sink
            value tcp-connection  Connection
    timeout value integer         ms          optional
   protocol value IOProtocol      Protocol    optional
where
Use tcp-sink to obtain an external output object, permitting writes on the connection.
You must include the following line at the beginning of your OmniMark program: 
include "omtcp.xin"
Connection must exist (else external exception TCP05).
Protocol cannot be Single-Packet (else external exception TCP19).
There may not be an active external source derived from Connection with tcp-sink (else external exception TCP20).
The timeout value applies to individual write operations. External exception TCP06 is thrown if the write operation times out. If a timeout value is not specified, this function blocks until data is written, or until an error occurs.
tcp-sink can be called once or more than once for a connection, but only if called serially. All streams derived from a tcp-sink write to the same output stream attachment, but may each have their own transformation logic and buffering.
  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-sink Connection-1
           protocol IOProtocolMultiPacket
     put s ("=" ||* 3048 || "%n") ||* 10
     put s "hello world"
     close s
     repeat
        exit unless tcp-is-connected Connection-1
        output tcp-get Connection-1
     again
| ---- |