Special Command Tags
[TCP] Transmission Control Protocol
   
Format OPEN (chan[,fileopt])"[TCP][server];socket[;tcp_opts]"
 
Where:
[TCP] File tag that tells ProvideX the channel is being opened for a TCP/IP
connection.
chan Channel or logical file number to open.
fileopt File options. Supported options include:
BSZ=num Block size (max. 32000).Defaults: READ=1024, WRITE=32000.
ERR=stmtref Error transfer
TIM=num Time-out value
server Server address. Optional. If specified (to denote a client connection on the channel), use either an IP address like 172.16.1.1 or a DNS
(Domain Name System) server, such as www.pvx.com. Omit it to indicate a host connection.
socket TCP/IP socket number. For a host connection, this is the socket number where the host listens and the client connects. For a client connection, this is the socket number where the host listens. The valid range for [TCP] sockets is 1 to 65535. (For an invalid socket number, less than 0 or greater than 65535, the OS dynamically assigns an unused valid number.)
For more information, see
System Limits
tcp_opts Options to override default TCP characteristics. When including a list, use the semicolon as a separator. Supported options are:
BINDTO=x.x.x.x This attribute forces the TCP/IP server connection to only use the network adpater that has the specified IP address x.x.x.x. It can be used on systems that have multiple adapters (network cards) in order to restrict the connection to a specifc network.
KEEPALIVE Use this attribute to force the OS to send keepalive packets between the client and the host, thereby helping assure that the TCP/IP connection is live.
NODELAY Disables algorithm that delays transmission. Default: delay up to 200ms., attempt to combine data into larger packets.
ONESHOT For host. Only accept a single connection then halt listening to the port. This option allows a server to monitor a port for a connection and immediately free the port once a connection is established. Default: multiple clients (not single).
This is
+PxPlus Exclusive
REUSE This option can be specified for a server connection and allows the server to listen for incoming connections even if there is another task currently using the port specified. This allows multiple processes to monitor the same incoming port and/or allows a server to start listening on a port even if a preceeding task has not fully severed its connection.
SINGLE For host. One client per time per connection. Secondary connections will be disconnected. Default: multiple clients (not single).
STREAM Sets streaming data mode. Default: block mode.
Description The [TCP] tag is used as a prefix in an OPEN statement to denote that ProvideX is to open the channel for a TCP/IP connection.

The TCP interface in ProvideX acts like a "smart" two-way communications pipe. A ProvideX TCP connection can be either a Server or Client-style connection; these are explained in the following sections. A single program can have many TCP sockets opened concurrently, with each independent of the others. However, there are operating system limitations. For more information, see System Limits.

TCP Server Connection

Omit the server value from the TCP OPEN syntax to notify ProvideX that the channel is to be opened as a host/server.

Example:

OPEN (1,BSZ=8192)"[TCP];10000"

This opens a TCP channel as a host/server connection with a block size of 8192 bytes. A host/server can communicate with more than one client at a time. (You can override this by using SINGLE as one of your tcp_opts.)

TCP Client Connection

Include the optional server, to notify ProvideX that the channel is to be opened as client connection linked to the socket where the host is listening; i.e., this opens a channel to create a link to the host's socket number. A client can only communicate with the specific host to which it is connected.

Examples:

OPEN (1,BSZ=16384)"[TCP]172.16.1.1;10000"

The example above opens a client link to a TCP channel, port 10000 on the server. The client PC uses any available socket number for its side of the communications. Note that the local machine dynamically assigns an available socket for your program to use.

The KEF( ) Function, can be used to identify local sockets; e.g.,

LET MY_KEY$=KEF(CHAN)

The data in MY_KEY$is in IP format, "10.12.1.12;80;GORDD".

As another example, open (1)"[tcp]www.microsoft.com;80;nodelay" opens a connection to Microsoft's website, which is listening to socket number 80 (the default). This also turns off the 200ms delay packet optimization algorithm.

   
See Also OPEN Directive
TCP/IP Access Specifications in the ProvideX User's Guide