concept remote server in category fortran

appears as: remote server
Modern Fortran: Building efficient parallel applications

This is an excerpt from Manning's book Modern Fortran: Building efficient parallel applications.

Now that we have a derived type to interface with the ipaddr struct, let’s create an instance of it. libdill provides two functions to instantiate the ipaddr struct: ipaddr_local and ipaddr_remote. The former is used on the server side, where you want to open up a socket to listen to incoming connections. The latter is used on the client side, where you want to connect to a socket on a remote server.

Listing 11.8. Fortran TCP client that creates a connection to a remote server and does nothing more
language="fortran" linenumbering="unnumbered">program client

  use iso_c_binding, only: c_int, c_null_char, & #1
                           c_int64_t             #1
  use mod_dill, only: ipaddr, ipaddr_remote, & #2
                      IPADDR_IPV4, tcp_connect #2

  implicit none
  integer(c_int) :: rc, connection
  type(ipaddr) :: addr

  rc = ipaddr_remote(addr,                       & #3
                     '127.0.0.1' // c_null_char, & #3
                     5555_c_int,                 & #3
                     IPADDR_IPV4,                & #3
                     -1_c_int64_t)                 #3
  connection = tcp_connect(addr, -1_c_int64_t) #4

end program client