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

tcp.connect

 
 

Library: TCP/IP client and server support (OMTCP)
Import: omtcp.xmd
Return type: tcp-connection

Returns:


Declaration

define external tcp.connection function tcp.connect
       on value string HostName
       at value integer PortNum
  timeout value integer ms 	(optional)

Argument definitions

HostName
is the name or IP address of the host to be connected to.
PortNum
is the port to be connected to.
ms
is how long the function will attempt to make connection before aborting, expressed in milliseconds.


Purpose

Use tcp.connect in a client program to establish a connection to a server program that is running on a specific host machine and port.

Requirements

The address supplied for HostName must be valid (else external exception TCP01).

The port number must fall between 0 and 65535 (else external exception TCP14).

Usage

If the connection cannot be made for any reason, the function throws external exception TCP08.

If the timeout value is specified it applies only to the wait for the connection. If the timeout is exceeded, the connection fails.

If the timeout is not specified, tcp.connect "blocks" until a connection is made or some other cause of failure is encountered.

Example


  import "omtcp.xmd" prefixed by tcp.
  
  process
     local tcp.connection client
  
     set client to tcp.connect to "123.123.123.45" on 5600

    Related Syntax
   tcp.connection
   tcp.disconnect
   tcp.writer
   tcp.get-string
   tcp.peer-ip
   tcp.peer-name
   tcp.reader
   tcp.wait-for-input
   tcp.is-connected
   tcp.put-string
   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.