concept message in category fortran

appears as: messages, message, The message, message
Modern Fortran: Building efficient parallel applications

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

The GNU Fortran compiler can take many other options that control language rules, warning messages, optimization, and debugging. I encourage you to go ahead and skim through the manual. You can access it by typing man gfortran on the command line. If the manual pages aren’t available on your system, you can always access the most recent documentation for gfortran at https://gcc.gnu.org/onlinedocs/gfortran.

We’ll start by implementing the TCP server first. The heavy lifting of opening and listening on sockets, sending and receiving messages, and the TCP protocol itself will be handled internally by libdill and the operating system, so we won’t have to worry about the implementation details of these pieces. What we’ll focus on is correctly implementing the Fortran interfaces with libdill functions, and understanding what they do.

Listing 11.7. The main server loop, which accepts the incoming connection, attaches the TCP suffix, sends a message, and closes the connection
language="fortran" linenumbering="unnumbered">do
  connection = tcp_accept(socket, addr_remote, -1_c_int64_t)
  call ipaddr_str(addr, address_string)
  print *, 'New connection from ' // trim(address_string)
  connection = suffix_attach(connection, TCP_SUFFIX, 2_c_size_t)
  rc = msend(connection, 'Hello' // c_null_char, 5_c_size_t, -1_c_int64_t)
  connection = suffix_detach(connection, -1_c_int64_t)
  rc = tcp_close(connection, -1_c_int64_t)
end do