tcp-connection

data type

Library: TCP/IP client and server support (OMTCP legacy, OmniMark versions 6.0.2 - 7.0)
Include: omtcp.xin


Purpose

The tcp-connection OMX component represents a connection to a remote machine using the TCP/IP (Transmission Control/Internet) protocol. Once the connection is made, you can communicate with the remote machine.

Usage Notes

The OmniMark TCP/IP dynamic link library file ("omtcp.dll" or "omtcp.so") creates the tcp-connection OMX component. The related include file ("omtcp.xin") defines the interface to that component. To use tcp-connection components in your program, you must include the following include statement in your program:

     include "omtcp.xin"

The tcp-connection OMX component is not copyable. This means that when you set the value of one tcp-connection OMX variable to the value of another tcp-connection OMX variable, you end up with two variables pointing at the same external object. You are able to manipulate both variables, but those manipulations are being performed on the same TCP connection, whether you use the original tcp-connection OMX variable or its copy.

Example

Within your program, you can create as many instances of the tcp-connection OMX component as you require by declaring global and local variables of type "tcp-connection".

     include "omtcp.xin"
     
     global tcp-connection Connection-1
     global tcp-connection Connection-2
     
     process
        local tcp-connection Connection-3
        local tcp-connection Connection-4

Once you have declared your tcp-connection OMX variables, you can use those variables to create TCP connections to remote machines using the tcp-connect function in the TCP/IP legacy library.

     include "omtcp.xin"
     
     process
        local tcp-connection Connection-1
        
        set Connection-1 to tcp-connect on "banzai.com" at "5600"
        

Assuming no errors occur when establishing the connection to the remote machine, you can now communicate with that machine via the TCP protocol using the other tcp-connection functions.