nanomsg sockets library for Fortran

A little background:  nanomsg is a sockets library that provides several communication patterns that are designed to be the building blocks for distributed systems.  Built in C, it was created by the lead developer of ZeroMQ, Martin Sustrik.  It is light, powerful, and succinct.

Up until now, sockets-based network communication in Fortran was limited (as far as I know) to using the winsock2 library put together by Intel(?).  Succinctness was not its strong point.  But with the advent of nanomsg and the use of the iso_c_binding intrinsic module standardized by Fortran 2003, I have developed Fortran bindings for nanomsg that will allow for very easy (and succinct!) sockets-based communication:

Included in the nanomsg.f90 file are examples for most of the functions.  I’m confident that there shouldn’t be any problems, but if there are, please let me know by opening an issue on github or leaving a comment here.

One final note: Not only is Fortran 2003 is required for this, but you will also need to compile the nanomsg library and include it in your projects to make this work.



3 responses to “nanomsg sockets library for Fortran

  1. Ram September 27, 2014 at 10:28 PM

    Thank you for this bindings library. Could you pls post a full socket example in fortran using these bindings.

  2. Alex M December 22, 2014 at 6:09 AM

    Hi John,

    Thank you so much for putting together the library. I’ve used some of your examples as the basis for a control systems project I’m working on. They’re very helpful. But I’m stuck on implementing the example given in Tim Dysinger’s blog on establishing a pipeline; specifically how to ‘nn_recv” without stipulating the size of the character array prior to it being received. (In your example you fix the size of the array.)

    The nanomsg documents say, “let the buf parameter be a pointer to a void* variable (pointer to pointer) to the receive buffer and set the len parameter to NN_MSG”. Are you able to offer any guidance on how to implement this in Fortran? What might need to modified in your example to achieve this?



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s