OpenNet Statement

Open a TCP/IP network port.

Syntax
OpenNet #portNumber As { Client | Server }​

Parameters

portNumber
Specify an integer value of the TCP/IP port number to be opened. Range is from 201 to 216.

Description
OpenNet opens a TCP/IP port for communication with another computer on the network.

One system should open as Server and the other as Client. It does not matter which one executes first.

See Also
ChkNet, CloseNet, SetNet

OpenNet Statement Example
For this example, two controllers have their TCP/IP settings configured as follows:

Controller #1:
Port: #201
Host Name: 192.168.0.2
TCP/IP Port: 1000

Function tcpip
  OpenNet #201 As Server
  WaitNet #201
  Print #201, "Data from host 1"
Fend

Controller #2:
Port: #201
Host Name: 192.168.0.1
TCP/IP Port: 1000

Function tcpip
  String data$
  OpenNet #201 As Client
  WaitNet #201
  Input #201, data$
  Print "received '", data$, "' from host 1"
Fend