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

tcp.reader

 
 

Library: Net, TCP/IP client and server support (OMTCP)
Import: omtcp.xmd
Return type: Source
Returns: 

An external source containing the data read from the tcp connection.


Declaration

  define external source function tcp.reader
    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 read operation to complete, expressed in milliseconds.
Protocol
specifies which I/O protocol is to be used.


Purpose

Use tcp.reader to obtain an external source object from which data will be read.

Requirements

Connection must exist (else external exception TCP05).

There may not be an active external source derived from Connection with tcp.reader (else external exception TCP04).

Usage Notes

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.reader 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.

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.get-string from Connection-1
           protocol tcp.multi-packet

     put s "hello world"
     close s

     output tcp.reader of Connection-1
           protocol tcp.multi-packet

    Related Syntax
   tcp.connection
   tcp.disconnect
   tcp.writer
   tcp.get-string
   tcp.peer-ip
   tcp.peer-name
   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 ] [ LEGACYLIBRARIES ] [ ERRORS ]

OmniMark 7.1.2 Documentation Generated: June 28, 2005 at 5:45:50 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © Stilo Corporation, 1988-2005.