| Syntax 
   define external stream function TCPConnectionGetCharacters
      value TCPConnection this-TCPConnection
      size value counter minimum-read-length optional
      variable-to size value counter maximum-read-length optional
     timeout value counter timeout-in-milliseconds optional
  as TCPConnectionGetCharacters
 Purpose
 
 This function reads characters received from a source on the TCP connection object. 
 There are four combinations for specifying the size and variable-to values, as follows:
 If neither is specified, then TCPConnectionGetCharactersreturns as many characters as it has available, as long as it has at least one character. It will wait (only for as long as the timeout value if one is specified) for at least one character, only if it has no characters to return.If only the size value is specified, TCPConnectionGetCharactersreads and returns exactly minimum-read-length characters. If a timeout value is specified and is exceeded, it will return immediately with the (zero or more) characters it has available. It will also set the TCP connection to be in error.If only the variable-to value is specified, then TCPConnectionGetCharactersreads as many characters as it has available, as if neither size nor variable-to were specified, except that if it has more than maximum-read-length available, it will only return maximum-read-length and will save any remaining characters for a subsequent read.If both the size and variable-to values are specified, then TCPConnectionGetCharactersreads at least minimum-read-length characters, but will return up to maximum-read-length characters, if it has them available. Like the size value only case, it can timeout in reading the first minimum-read-length characters, but will not do so once that many have been read. It is an error for the size value to be greater than the variable-to value.
 If the passed TCP connection object is closed or was never connected, then this function returns zero characters. At the same time, it sets the TCP connection to be in error. If an error is encountered during reading, either zero characters or those already read (if any) are returned, as seems appropriate, and the TCP connection object is set to be in error. 
 Note that difficulties inherent in deriving multiple sources from a connection apply equally to using TCPConnectionGetCharacterswhen aTCPConnectionGetSourcederived source is also active. Note, however, that sequential uses ofTCPConnectionGetCharactersare allowed. It is also guaranteed that aTCPConnectionGetCharacterswill only ever read the characters it returns from a source. Any following characters are available to the nextTCPConnectionGetSource,TCPConnectionGetCharacters, orTCPConnectionGetLine. Any attempt to do a TCPConnectionGetCharacterswhen the associated TCP connection has been closed usingTCPConnectionCloseis in error, and will set the TCP connection to be in error. Any attempt to do a TCPConnectionGetCharacterswhen there is already an active source derived fromTCPConnectionGetSourceis not allowed and will result in an OmniMark external function exception. Arguments:
 "this-TCPConnection" is an opaque object of type TCPConnection.
"minimum-read-length" is the minimum number of characters TCPConnectionGetCharacterswill read."maximum-read-length" is the maximum number of characters TCPConnectionGetCharacterswill read."timeout-in-milliseconds" is the length of time the function will run for before terminating automatically. 
 Example
   local TCPConnection TCP-Conn
  set TCP-Conn to TCPConnectionOpen on "localhost" at 5300
  repeat
     exit unless TCPConnectionIsConnected TCP-Conn
     output TCPConnectionGetCharacters TCP-Conn
  again
 |