C Collection of code snippets by Arne Vajhøj 
C (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
      program p5
      implicit none
      integer*4 port
      character*32 host
      parameter (port=12345,
     +           host='localhost')
      integer*4 sd,msglen
      character*100 outmsg
      character*10000 inmsg
      integer*4 vms_socket_open,vms_socket_recv
      external vms_socket_open,vms_socket_recv
c  open connection
      sd=vms_socket_open(host,port)
c  send message
      outmsg='Hi from Fortran!'
      call vms_socket_send(sd, outmsg)
c  reaceive all messages
100   if(vms_socket_recv(sd, inmsg, msglen).gt.0) then
        write(*,*) '|'//inmsg(1:msglen)//'|'
        goto 100
      end if
c  close connection
      call vms_socket_close(sd)
      end
