# Module `trap` - An asynchronous network messaging system for occam-pi

An asynchronous network messaging system for occam-pi.

The Trap nameserver `trapns` must be running in order for Trap programs to find each other. By default, it will assume the nameserver is running on `localhost`; to specify where it really is, create a file called `.trap.ns` in the current directory containing the hostname.

## Index

- Channel type `TRAP.CHANNEL.CT` - Interface for a listening Trap port
  - Variable `msg?` - Messages received from the port
- Channel type `TRAP.CT` - Handle to the Trap server
- Tag `open` - Replies
- Process `trap.open` - Open a Trap port
- Process `trap.send` - Send data to a Trap port
- Process `trap.start` - Start the Trap server

## Declarations

### `trap.inc`:43Channel type `TRAP.CHANNEL.CT`

`CHAN TYPE TRAP.CHANNEL.CT`

Interface for a listening Trap port.

### `trap.inc`:45Variable `msg?`

`CHAN MOBILE []BYTE`

Messages received from the port.

### `trap.inc`:52Tag `open`

`open; INT`

Replies ``.

### `trap.inc`:62Channel type `TRAP.CT`

`CHAN TYPE TRAP.CT`

Handle to the Trap server.

### `trap.occ`:464Process `trap.start`

`PROC trap.start (VAL INT node, RESULT SHARED TRAP.CT! control)`

Start the Trap server.

### `trap.occ`:473Process `trap.open`

`PROC trap.open (SHARED TRAP.CT! trap, VAL INT port, RESULT TRAP.CHANNEL.CT? chan)`

Open a Trap port.

### `trap.occ`:483Process `trap.send`

`PROC trap.send (SHARED TRAP.CT! trap, VAL INT node, port, MOBILE []BYTE data)`

Send data to a Trap port.