[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.21 OPEN

Opens sequential or socket I/O devices and files and associates them with a numeric FreeM input/output channel.

Syntax (Sequential Files)

 
OPEN:postcondition channel:"filename/access-mode"

Opens filename for reading and/or writing, and associates the file with FreeM I/O channel channel, provided that the optional postcondition is true or omitted. The below table lists the valid options for access-mode:

r

Read-only access

w

Create a new file for write access

a

Write access; append to existing file

r+

Read/write access

I/O Path

You cannot specify a fully-qualified filesystem path in the FreeM OPEN command. By default, FreeM will assume that filename exists in the directory indicated in ^$JOB($JOB,"CWD"). If you wish to access files in other directories, you must first set the I/O Path in ^$JOB($JOB,"IOPATH").

The following example will set the I/O path to /etc:

 
SET ^$JOB($JOB,"IOPATH")="/etc"

If channel was already OPENed in the current process, calling OPEN on the same channel again implicitly closes the file or device currently associated with channel.

Syntax (Network Sockets)

Network sockets use a dedicated range of FreeM I/O channels ranging from 100-255. OPENing a socket I/O channel does not implicitly connect the socket. Connecting the socket to the specified remote host is accomplished by the /CONNECT control mnemonic supplied to the USE command.

 
  OPEN:postcondition socket-channel:"hostname-or-address:port:address-family:connection-type"

Socket Parameters

socket-channel

The socket I/O channel to use. This must be in the range of 100-255.

hostname-or-address

The hostname or IP address to connect to. If a hostname is supplied, OPEN will implictly do a name lookup, the mechanism of which is typically determined by the configuration of /etc/nsswitch.conf on most UNIX and UNIX-like platforms.

port

The TCP or UDP port to which the socket will connect on the remote host.

address-family

The address family to use. Either IPV4 or IPV6.

connection-type

Which connection type to use. Either TCP or UDP.

If you do not specify the address family and connection type, they will default to IPV4 and TCP, respectively.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated by root on October 14, 2020 using texi2html 1.82.