# Message-oriented Communication

## Message Oriented Communication (Socket)

* A **socket** is **a communication end point** to which an application can write data that are to be sent out over the underlying network, and from which incoming data can be read.
* A socket forms **an abstraction over the actual port** that is used by the local operating system for a specific transport protocol.
* Common operations include:
  * `socket`: create a new communication end point
  * `bind`: attach a local address to a socket
  * `listen`: tell operating system what the maximum number of pending connection requests should be
  * `accept`: **block caller until a connection request arrives**
  * `connect`: actively attempt to establish a connection
  * `send`: send some data over the connection
  * `receive`: receive some data over the connection
  * `close`: release the connection

## Message-Passing Interface (MPI)

* MPI is designed for **parallel applications** and as such is tailored to **transient communication**.
* Support different network protocol stacks.
* Common operations include:
  * `MPI_bsend`: append outgoing message to a local send buffer (**transient asynchronous communication**)
  * `MPI_send`: send a message and wait until copied to local or remote buffer
  * `MPI_ssend`: send a message and wait until transmission starts (**synchronous communication**)
  * `MPI_sendrecv`: send a message and wait for reply (**strongest form of synchronous communication**)
  * `MPI_isend`: pass reference to outgoing message, and continue
  * `MPI_issend`: pass reference to outgoing message, and wait until receipt starts
  * `MPI_recv`: receive a message; block if there is none
  * `MPI_irecv`: check if there is an incoming message, but do not block
