# openInOut -- open an input output file

## Synopsis

• Usage:
openInOut f
• Inputs:
• Outputs:
• an open input output file

## Description

There are various options for the argument f.

• a string not starting with ! or $: the string is taken as the name of an input output file to open. For example, in Unix, it might be a named pipe. A filename starting with ~/ will have the tilde replaced by the user's home directory. • a string of the form "!cmd": the command cmd will be started, and two pipes will be opened, connected to its standard input and standard output file descriptors. Warning: pipes hold only 4096 bites, so if you write more than that to the resulting input output file (as input for the command) without reading any data, you may block while the command is blocked waiting to write more output; in this case, Macaulay2 will appear to hang. • a string of the form "$hostname:service": a connection will be made to the specified service at the specified host. If the service port is omitted, along with the colon, then port 2500 is used. If the hostname is omitted, an incoming connection will be waited for.
• a listener created previously by openListener: a new connection will be created. To avoid blocking the Macaulay2 process while waiting for the incoming connection, use isReady.

In order to open a socket successfully, there must be a process accepting connections for the desired service on the specified host.

The various forms listed above can be used also with all other input output operations that open files, such as openIn, openOut, get, and <<, with data transfer possible only in the direction specified. A possibly confusing asymmetry is that with openIn "!foo" or with get "!foo" the standard input of the command foo is closed, but with openOut "!foo" the standard output of the command foo is connected to the standard output of the parent Macaulay2 process.