Skip to main content

connection

A unidirectional channel between two components: one always sends, the other always receives. Traffic in both directions is two connections.

component Radar;
component CommandPost;

connection TrackFeed from Radar to CommandPost;

Declarations​

A named connection is declared at top level. An unnamed connection already exists for every ordered pair of components, and a statement that names no connection travels on that one.

  • The name is a global declaration — unique within its file, and importable.
  • from and to each name a component, and both are written. There is no bidirectional form.
  • Several connections may join the same pair of components. A statement picks one by name.
component Radar;
component CommandPost;

connection TrackFeed from Radar to CommandPost;
connection SlewLink from CommandPost to Radar;

Clauses​

send, recv, and exch all end with a connection clause, which says which components the message travels between and which connection carries it: from A, to B, on Link, or a combination.

  • At least one part is present. from and to name components, on names a connection.
  • An omitted endpoint is derived from the on connection, whose declaration fixes both ends. A written endpoint is never overridden.
  • In a send the sender is the component the statement is written in, and in a recv the receiver is. Writing that component out is allowed and says nothing new; writing a different one is an error.
  • Derivation works the same for send, recv, and exch, and for an imported connection as for a local one.
component Radar;
component CommandPost;

message struct TrackReport {
    track_id: uint32;
}

connection TrackFeed from Radar to CommandPost;

local protocol Sweep in Radar {
    send any TrackReport to CommandPost;
    send any TrackReport from Radar to CommandPost;
    send any TrackReport to CommandPost on TrackFeed;
    send any TrackReport on TrackFeed;
}

The four statements send the same message to the same component. The first travels on the unnamed connection; the last takes both endpoints from TrackFeed.

Errors​

An endpoint that is not a component​

component CommandPost;

message struct TrackReport {
    track_id: uint32;
}

connection TrackFeed from TrackReport to CommandPost;   // error: connection-target-not-component

A clause part that names the wrong kind of declaration​

component Radar;
component CommandPost;

message struct TrackReport {
    track_id: uint32;
}

local protocol Sweep in Radar {
    send any TrackReport to CommandPost on TrackReport;   // error: connection-clause-target
}

A statement that names another component in its own role​

component Radar;
component CommandPost;

message struct TrackReport {
    track_id: uint32;
}

local protocol Sweep in Radar {
    send any TrackReport from CommandPost to Radar;   // error: connection-directionality
}

A clause that runs against the connection it names​

component Radar;
component CommandPost;

message struct TrackReport {
    track_id: uint32;
}

connection TrackFeed from Radar to CommandPost;

local protocol Sweep in Radar {
    send any TrackReport to Radar on TrackFeed;   // error: connection-directionality
}
  • component — the participants a connection joins.
  • send — the statement that puts a message on a connection.
  • recv — the statement that takes one off.
  • exch — both halves as one global statement.