swirl
Guide to OmniMark 8   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Syntax     Other Library Functions  
function  

tcp.writer

 
 

Library: TCP/IP client and server support (OMTCP)
Import: omtcp.xmd
Return type: String sink

Returns: An external output through which data can be written to the tcp connection.


Declaration

define external string sink function tcp.writer
  of       value tcp.connection   Connection
  timeout  value integer          ms          optional
  protocol value tcp.io-protocol  Protocol    optional

Argument definitions

Connection
is an existing tcp.connection object.
ms
is the time to wait for a write operation to complete, expressed in milliseconds.
Protocol
specifies which I/O protocol is to be used.


Purpose

Use tcp.writer to obtain an external output object, permitting writes on the connection.

Requirements

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.writer (else external exception TCP20).

Usage Notes

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.writer can be called once or more than once for a connection, but only if called serially. All streams derived from a tcp.writer write to the same output stream attachment, but may each have their own transformation logic and buffering.

Example


  import "omtcp.xmd" prefixed by tcp.
  
  process
     local tcp.connection Connection-1
     local stream s
  
     set Connection-1 to tcp.connect to "localhost" on 5300
     tcp.set-buffering of Connection-1 enabled false
  
     open s with binary-mode as
        tcp.writer of Connection-1
           protocol tcp.multi-packet
  
     put s ("=" ||* 3048 || "%n") ||* 10
     put s "hello world"
     close s
  
     repeat
        exit unless tcp.is-connected Connection-1
        output tcp.get-string from Connection-1
     again

    Related Syntax
   tcp.connection
   tcp.disconnect
   tcp.get-string
   tcp.peer-ip
   tcp.peer-name
   tcp.reader
   tcp.wait-for-input
   tcp.is-connected
   tcp.put-string
   tcp.connect
   tcp.set-buffering
   tcp.terminate-reader
 
  Other Library Functions
   tcp.accept-connection
   tcp.connect
   tcp.connection
   tcp.create-service
   tcp.destroy-service
   tcp.disconnect
   tcp.end-delimited
   tcp.get-string
   tcp.is-connected
   tcp.multi-packet
   tcp.omtcp-version
   tcp.peer-ip
   tcp.peer-name
   tcp.port
   tcp.put-string
   tcp.reader
   tcp.service
   tcp.set-buffering
   tcp.single-packet
   tcp.terminate-reader
   tcp.wait-for-input
   tcp.writer
 
 

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ LEGACY LIBRARIES ] [ ERRORS ]

OmniMark 8.2.0 Documentation Generated: March 13, 2008 at 3:27:39 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2008.