12.9.6. Client/Server Examples

PreviousUpNext
Up: Establishing Communication Next: Other Functionality Previous: Reserved Key Values


Example Simplest Example---Completely Portable.

The following example shows the simplest way to use the client/server interface. It does not use service names at all.

On the server side:

Image file

The server prints out the port name to the terminal and the user must type it in when starting up the client (assuming the MPI implementation supports stdin such that this works). On the client side:

Image file


Example Ocean/Atmosphere---Relies on Name Publishing

In this example, the ``ocean'' application is the ``server'' side of a coupled ocean-atmosphere climate model. It assumes that the MPI implementation publishes names.

Image file

On the client side:

Image file


Example Simple Client-Server Example

This is a simple example; the server accepts only a single connection at a time and serves that connection until the client requests to be disconnected. The server is a single process.

Here is the server. It accepts a single connection and then processes data until it receives a message with tag 1. A message with tag 0 tells the server to exit.

Image file

Here is the client.

Image file


PreviousUpNext
Up: Establishing Communication Next: Other Functionality Previous: Reserved Key Values


Return to MPI-4.1 Standard Index
Return to MPI Forum Home Page

(Unofficial) MPI-4.1 of November 2, 2023
HTML Generated on November 19, 2023