<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: FORTRAN using TCPIP gethostbyname in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6885653#M37645</link>
    <description>&lt;P&gt;&amp;gt; Post the code [...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Still a good idea.&lt;/P&gt;&lt;P&gt;&amp;gt; I've also tried to call the C gethostbyname function, but the return&lt;BR /&gt;&amp;gt; code is always zero.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; I can do that, too, but with my weak psychic powers, I can't say that&lt;BR /&gt;your (invisible) code has the same defect as my demo.&amp;nbsp; Works:&lt;BR /&gt;&lt;BR /&gt;alp $ fort ghbn_1&lt;BR /&gt;alp $ link ghbn_1&lt;BR /&gt;alp $ run ghbn_1&lt;BR /&gt;&amp;nbsp; decc$gethostbyname() = 270352&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Fails:&lt;BR /&gt;&lt;BR /&gt;alp $ fort ghbn_2&lt;BR /&gt;alp $ link ghbn_2&lt;BR /&gt;alp $ run ghbn_2&lt;BR /&gt;&amp;nbsp; decc$gethostbyname() = 0&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; The (working) program:&lt;/P&gt;&lt;P&gt;alp $ type ghbn_1.for&lt;BR /&gt;c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Example (lame) calling gethostbyname().&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; program ghbn&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; implicit none&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; character* 256 name&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; integer* 4 he_p&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; integer* 4 decc$gethostbyname&lt;BR /&gt;&lt;BR /&gt;c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NUL-terminate the name.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name = 'ftp.hpe.com'// char(0)&lt;BR /&gt;&lt;BR /&gt;c &amp;nbsp; &amp;nbsp; Get the address of a hostent structure.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; he_p = decc$gethostbyname( %ref( name))&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type *, " decc$gethostbyname() = ", he_p&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; How to make it fail:&lt;BR /&gt;&lt;BR /&gt;alp $ gdiff ghbn_1.for ghbn_2.for&lt;BR /&gt;5c5&lt;BR /&gt;&amp;lt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; implicit none&lt;BR /&gt;---&lt;BR /&gt;&amp;gt; ccc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; implicit none&lt;BR /&gt;10c10&lt;BR /&gt;&amp;lt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; integer* 4 decc$gethostbyname&lt;BR /&gt;---&lt;BR /&gt;&amp;gt; ccc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; integer* 4 decc$gethostbyname&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; That is, failing to declare decc$gethostbyname as an integer is an&lt;BR /&gt;easy way to get an apparently bad result.&amp;nbsp; "implicit none" was, I claim,&lt;BR /&gt;the best thing ever to happen to FORTRAN/Fortran.&lt;/P&gt;</description>
    <pubDate>Fri, 05 Aug 2016 00:08:41 GMT</pubDate>
    <dc:creator>Steven Schweda</dc:creator>
    <dc:date>2016-08-05T00:08:41Z</dc:date>
    <item>
      <title>FORTRAN using TCPIP gethostbyname</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6884503#M37637</link>
      <description>&lt;P&gt;Does anyone have an example of using host name lookup in FORTRAN.&lt;/P&gt;&lt;P&gt;I've tried to use QIO with IO$_ACPCONTROL but get access violations.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've also tried to call the C gethostbyname function, but the return code is always zero.&lt;/P&gt;&lt;P&gt;It seems this question was asked to the openvms wizard a long time ago.&lt;/P&gt;&lt;P&gt;&lt;A href="http://h71000.www7.hp.com/wizard/wiz_7265.html" target="_blank"&gt;http://h71000.www7.hp.com/wizard/wiz_7265.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I have a FORTRAN program talking to the remote server (python on a raspbrry pi) based on the example&lt;/P&gt;&lt;P&gt;&lt;A href="http://h71000.www7.hp.com/wizard/wiz_2777.html" target="_blank"&gt;http://h71000.www7.hp.com/wizard/wiz_2777.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;However it's frustrating to have the ip address coded into the program. I'm using FORTRAN because the existing application is FORTRAN.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 11:40:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6884503#M37637</guid>
      <dc:creator>Frank_Gribbin</dc:creator>
      <dc:date>2016-08-02T11:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN using TCPIP gethostbyname</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6884579#M37638</link>
      <description>&lt;P&gt;Post the code that gets the ACCVIO. &amp;nbsp;Usually this happens because the parameters are not passed correctly. &amp;nbsp;It may be a simple fix to your existing code.&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 15:06:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6884579#M37638</guid>
      <dc:creator>abrsvc</dc:creator>
      <dc:date>2016-08-02T15:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN using TCPIP gethostbyname</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6884594#M37639</link>
      <description>&lt;P&gt;&amp;nbsp;&amp;nbsp; It's sure been a long time since I did anything with Fortran.&amp;nbsp; I seem&lt;BR /&gt;to have forgotten most of it.&amp;nbsp; The following is crude, but might be&lt;BR /&gt;helpful.&amp;nbsp; (I assume that some of those modern POINTER things might look&lt;BR /&gt;less goofy than deref(), for example.)&amp;nbsp; The QIO method would probably be&lt;BR /&gt;smarter.&lt;/P&gt;&lt;P&gt;alp $ fort ghbn&lt;BR /&gt;alp $ link ghbn&lt;BR /&gt;alp $ run ghbn&lt;BR /&gt;addr = 216.237.214.019&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;gt; Post the code [...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; For us non-psychics, it's tough to guess what you did wrong without&lt;BR /&gt;seeing what you did.&amp;nbsp; (If I can post the above embarrassment, then you&lt;BR /&gt;should be able to reveal yours.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The file ghbn.for does not have a valid extension for an&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attachment and has been removed. jpg,gif,png are the valid&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; extensions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; These forums get stupider by the day.&amp;nbsp; Your Web browser may hate&lt;BR /&gt;this non-JPEG ".jpg" file, but it should be willing to save it.&lt;BR /&gt;Otherwise, it should be possible to use Wget to fetch the file.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 15:53:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6884594#M37639</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2016-08-02T15:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN using TCPIP gethostbyname</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6884702#M37640</link>
      <description>&lt;P&gt;The answer that the Wizard gave is still correct. &amp;nbsp;You are using OpenVMS, which means that there simply are not examples of every&amp;nbsp;call in every language. &amp;nbsp; &amp;nbsp;What was available of for programming examples for OpenVMS largely disappeared off the net a decade or more ago, unfortunately. &amp;nbsp; This means learning the &lt;A href="http://h71000.www7.hp.com/doc/82final/5973/5973pro.html" target="_blank"&gt;OpenVMS calling standard&lt;/A&gt; and argument passing, and how that applies to this and other calls (call by value, call by reference, descriptor by address, etc), and how to use examples of one call for some other call. &amp;nbsp; &amp;nbsp;Other example calls from usenet newsgroups such as comp.os,vms, or from the OpenVMS Freeware, or elsewhere.&lt;/P&gt;&lt;P&gt;Here, you can also translate an application-specific logical name — not my favorite approach — or can read the IP address from a data file, and bypass the problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For this case, using the OpenVMS APIs? &amp;nbsp; &amp;nbsp;Fortran isn't going to want to call gethostbyname() call directly either, as that call returns a pointer to a structure. &amp;nbsp; &amp;nbsp;Fortran pointers differ somewhat from how C pointers work. &amp;nbsp; (Might also need to call the CRTL initialization routine decc$crtl_init call here too, if you're heading down that path and planning to use jackets and calls into the C RTL from an application with a main program written in a language other than C.) &amp;nbsp; Which means you're either going to be &lt;A href="http://h20565.www2.hpe.com/hpsc/doc/public/display?docId=emr_na-c04622282" target="_blank"&gt;using $qio calls&lt;/A&gt;&amp;nbsp;(e.g. see 2.16.2 for the general sequence, though that example is in C, and also &lt;A href="https://groups.google.com/d/msg/comp.os.vms/8Sru7q411wI/6bhlcgQ2N_YJ" target="_blank"&gt;see some of the old discussions from comp.os.vms newsgroup&lt;/A&gt;)&amp;nbsp;to get the data from TCP/IP Services, or you're going to be using a wrapper around the C call to dereference and pass the data to the Fortran code. &amp;nbsp; (&lt;A href="http://aea.web.psi.ch/Urs_Rohrer/MyWeb/sample2.htm" target="_blank"&gt;There are examples of the latter approach posted&lt;/A&gt;.)&lt;/P&gt;&lt;P&gt;FWIW, consider avoiding the IPv4-only&amp;nbsp;gethostbyname() and gethostbyaddr() calls in any new code. &amp;nbsp; The&amp;nbsp;getaddrinfo() and getnameinfo() calls are the preferred approach in new code. &amp;nbsp;(While OpenVMS does now have these two C calls and related baggage, &lt;A href="https://groups.google.com/d/msg/comp.os.vms/7msyan1fj3w/pxSKPSJoAwAJ" target="_blank"&gt;there are wrinkles&lt;/A&gt;, and&amp;nbsp;&lt;A href="https://groups.google.com/d/msg/comp.os.vms/MzsDGZTccq8/5s7M6GTZ68wJ" target="_blank"&gt;unfortunately&amp;nbsp;there does not appear to be any documented $qio function code associated with these&lt;/A&gt;.)&lt;/P&gt;&lt;P&gt;If you're just starting to learn IP networking, &lt;A href="http://beej.us/guide/bgnet/" target="_blank"&gt;there are available resources&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;The comp.os.vms usenet newsgroup gets more traffic than this place, too. &amp;nbsp; To access that usenet newsgroup, you can either use Google Groups (a front end which has its own issues, but the search usually works) or scrounge a newsreader for your preferred local operating system and register for a free Usenet account from one of the various providers, such as &lt;A href="http://www.eternal-september.org" target="_blank"&gt;Eternal September&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 18:53:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6884702#M37640</guid>
      <dc:creator>Hoff</dc:creator>
      <dc:date>2016-08-02T18:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN using TCPIP gethostbyname</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6884763#M37641</link>
      <description>&lt;P&gt;Thank you Steven Schweda!,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was always wondering how to deal with C functions returning pointers from FORTRAN. deref() might be rough, but it is simple and it works!.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 22:25:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6884763#M37641</guid>
      <dc:creator>Francisco Hermida</dc:creator>
      <dc:date>2016-08-02T22:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN using TCPIP gethostbyname</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6884770#M37642</link>
      <description>&lt;P&gt;&amp;gt; I was always wondering how to deal with C functions returning pointers&lt;BR /&gt;&amp;gt; from FORTRAN. deref() might be rough, but it is simple and it works!.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Glad to help.&amp;nbsp; (It's been so long that I can't remember where I stole&lt;BR /&gt;that idea.&amp;nbsp; It seems unlikely that I invented it.)&amp;nbsp; Of course, "deref"&lt;BR /&gt;is really a misnomer, because the real trick is the %val() in the&lt;BR /&gt;caller.&amp;nbsp; deref() simply returns what it gets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; It'd be nice if someone (perhaps someone who knows something about&lt;BR /&gt;pointers in Fortran) could explain how to deal with a C function like&lt;BR /&gt;getaddrinfo(), which returns pointers in arguments rather than as the&lt;BR /&gt;function value.&amp;nbsp; An alternative approach would be to write a&lt;BR /&gt;Fortran-friendly C wrapper for getaddrinfo(), but that would require a&lt;BR /&gt;Fortran user to have a C compiler, too.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 23:21:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6884770#M37642</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2016-08-02T23:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN using TCPIP gethostbyname</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6885489#M37643</link>
      <description>&lt;P&gt;Steven, I cobbled up the start of a routine that performs the appropriate pointer stuff in Fortran (using the DEC-specific POINTER (pointer,pointee), not the Fortran 95 Pointer types. &amp;nbsp;It needs more work to turn it into a callable function, and I don't have the IPV6 bits implemented, but it may work as a jumping off point or just give you ideas for your own approach.&lt;/P&gt;&lt;P&gt;I'll try to attach it here.&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;P&gt;example use:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;$&amp;nbsp;mcr []F_GETADDRINFO localhost&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;[LOCALHOST]&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;AI_Flags = 0&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;AI_Family = INET&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;AI_SockType = SOCK_STREAM&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;AI_Protocol = IP_TCP&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;AI_CannonName = [LOCALHOST]&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;SIN_Len = 16&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;SIN_Family = INET&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;SIN_Port = 0&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;IPV4 Address = 127.0.0.1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;AI_Flags = 0&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;AI_Family = INET&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;AI_SockType = SOCK_DGRAM&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;AI_Protocol = IP_UDP&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;AI_CannonName = [LOCALHOST]&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;SIN_Len = 16&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;SIN_Family = INET&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;SIN_Port = 0&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;IPV4 Address = 127.0.0.1&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2016 15:48:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6885489#M37643</guid>
      <dc:creator>Mike Kier</dc:creator>
      <dc:date>2016-08-04T15:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN using TCPIP gethostbyname</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6885635#M37644</link>
      <description>&lt;P&gt;&amp;gt; Steven, I cobbled up the start of a routine [...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Thanks for the helpful cobbling (including the better FORMAT).&amp;nbsp; My&lt;BR /&gt;more stone-age variation may be attached (depending on today's forum&lt;BR /&gt;vagaries).&lt;/P&gt;&lt;P&gt;alp $ fort gai&lt;BR /&gt;alp $ link gai&lt;BR /&gt;alp $ r gai&lt;BR /&gt;&amp;nbsp; getaddrinfo() = 0&lt;BR /&gt;&amp;nbsp; ai_flags = 0&lt;BR /&gt;&amp;nbsp; ai_family = 2&lt;BR /&gt;&amp;nbsp; ai_socktype = 1&lt;BR /&gt;&amp;nbsp; ai_protocol = 6&lt;BR /&gt;&amp;nbsp; ai_addrlen = 16&lt;BR /&gt;&amp;nbsp; ai_canonname_p = 0&lt;BR /&gt;&amp;nbsp; ai_addr_p = 2196368&lt;BR /&gt;&amp;nbsp; ai_next_p = 2390728&lt;BR /&gt;addr = 216.237.214.19&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2016 22:01:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6885635#M37644</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2016-08-04T22:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN using TCPIP gethostbyname</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6885653#M37645</link>
      <description>&lt;P&gt;&amp;gt; Post the code [...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Still a good idea.&lt;/P&gt;&lt;P&gt;&amp;gt; I've also tried to call the C gethostbyname function, but the return&lt;BR /&gt;&amp;gt; code is always zero.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; I can do that, too, but with my weak psychic powers, I can't say that&lt;BR /&gt;your (invisible) code has the same defect as my demo.&amp;nbsp; Works:&lt;BR /&gt;&lt;BR /&gt;alp $ fort ghbn_1&lt;BR /&gt;alp $ link ghbn_1&lt;BR /&gt;alp $ run ghbn_1&lt;BR /&gt;&amp;nbsp; decc$gethostbyname() = 270352&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Fails:&lt;BR /&gt;&lt;BR /&gt;alp $ fort ghbn_2&lt;BR /&gt;alp $ link ghbn_2&lt;BR /&gt;alp $ run ghbn_2&lt;BR /&gt;&amp;nbsp; decc$gethostbyname() = 0&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; The (working) program:&lt;/P&gt;&lt;P&gt;alp $ type ghbn_1.for&lt;BR /&gt;c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Example (lame) calling gethostbyname().&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; program ghbn&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; implicit none&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; character* 256 name&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; integer* 4 he_p&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; integer* 4 decc$gethostbyname&lt;BR /&gt;&lt;BR /&gt;c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NUL-terminate the name.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name = 'ftp.hpe.com'// char(0)&lt;BR /&gt;&lt;BR /&gt;c &amp;nbsp; &amp;nbsp; Get the address of a hostent structure.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; he_p = decc$gethostbyname( %ref( name))&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type *, " decc$gethostbyname() = ", he_p&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; How to make it fail:&lt;BR /&gt;&lt;BR /&gt;alp $ gdiff ghbn_1.for ghbn_2.for&lt;BR /&gt;5c5&lt;BR /&gt;&amp;lt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; implicit none&lt;BR /&gt;---&lt;BR /&gt;&amp;gt; ccc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; implicit none&lt;BR /&gt;10c10&lt;BR /&gt;&amp;lt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; integer* 4 decc$gethostbyname&lt;BR /&gt;---&lt;BR /&gt;&amp;gt; ccc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; integer* 4 decc$gethostbyname&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; That is, failing to declare decc$gethostbyname as an integer is an&lt;BR /&gt;easy way to get an apparently bad result.&amp;nbsp; "implicit none" was, I claim,&lt;BR /&gt;the best thing ever to happen to FORTRAN/Fortran.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 00:08:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6885653#M37645</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2016-08-05T00:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN using TCPIP gethostbyname</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6885728#M37646</link>
      <description>&lt;P&gt;&amp;gt; I've tried to use QIO with IO$_ACPCONTROL but get access violations.&lt;/P&gt;&lt;P&gt;&amp;gt; Post the code [...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Still a good idea.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Attached should be still more code in desperate need of refinement,&lt;BR /&gt;this time using $QIOW to do a GETHOSTBYNAME look-up.&lt;/P&gt;&lt;P&gt;alp $ fort qghbn&lt;BR /&gt;alp $ link qghbn&lt;BR /&gt;alp $ run qghbn&lt;BR /&gt;sys$assign() =&amp;nbsp;&amp;nbsp;&amp;nbsp; 00000001&lt;BR /&gt;sys$qiow() =&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 00000001&lt;BR /&gt;sys$qiow( iosb) = 00000001&lt;BR /&gt;&amp;nbsp; addr_len =&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;BR /&gt;addr = 216.237.214.19&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 05:12:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6885728#M37646</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2016-08-05T05:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN using TCPIP gethostbyname</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6890290#M37647</link>
      <description>&lt;P&gt;Thanks to everyone who replied. I'm sorry about being silent so long. I'd expected that the system would notify me when there were updates. Anyway I got on with my own solution, which was to write a C wrapper to gethostbyname that returned the address in a form my FORTRAN could access simply.&lt;/P&gt;&lt;P&gt;In the hope this may be of use to someone else or provoke more comments.&lt;/P&gt;&lt;P&gt;I wasn't aware of getaddrinfo. I'm using an old version of TCP/IP, with an older manual!&lt;/P&gt;&lt;P&gt;HP TCP/IP Services for OpenVMS Alpha Version V5.4 - ECO 7&lt;BR /&gt;on a AlphaStation 255/233 running OpenVMS V7.3-2&lt;/P&gt;&lt;P&gt;To run the example&lt;/P&gt;&lt;P&gt;$ &lt;a href="https://community.hpe.com/t5/user/viewprofilepage/user-id/1619304"&gt;@Test4&lt;/a&gt;&lt;/P&gt;&lt;P&gt;You'll want to specify a host name that exists&lt;/P&gt;&lt;P&gt;It seems I can't attach code examples, so I put in-line&lt;/P&gt;&lt;P&gt;TEST.FOR&lt;/P&gt;&lt;P&gt;PROGRAM TEST4&lt;BR /&gt;*+&lt;BR /&gt;*&lt;BR /&gt;* Program : TEST4&lt;BR /&gt;*&lt;BR /&gt;* Purpose : Test host name lookup&lt;BR /&gt;*&lt;BR /&gt;* Method :&lt;BR /&gt;*&lt;BR /&gt;* Called :&lt;BR /&gt;*&lt;BR /&gt;*&lt;BR /&gt;*-&lt;BR /&gt;* History :&lt;BR /&gt;* 03-Aug-2016 FJG Original version&lt;BR /&gt;*&lt;BR /&gt;** Include files **&lt;BR /&gt;*&lt;BR /&gt;INCLUDE 'sys$library:ucx$inetdef.for'&lt;BR /&gt;*&lt;BR /&gt;** Arguments **&lt;BR /&gt;* Given&lt;BR /&gt;* Modified&lt;BR /&gt;* Returned&lt;BR /&gt;*&lt;BR /&gt;** External routines **&lt;BR /&gt;*&lt;BR /&gt;INTEGER*4 get_host_address&lt;BR /&gt;EXTERNAL get_host_address&lt;BR /&gt;*&lt;BR /&gt;** Local parameters **&lt;BR /&gt;*&lt;BR /&gt;PARAMETER IBUFL=80&lt;/P&gt;&lt;P&gt;** Local variables **&lt;BR /&gt;*&lt;BR /&gt;CHARACTER*128 HOST_NAME&lt;BR /&gt;INTEGER*4 HOST_ADDRESS&lt;BR /&gt;*&lt;BR /&gt;&lt;BR /&gt;PRINT *,'Entering program test4'&lt;/P&gt;&lt;P&gt;HOST_NAME = 'lpas3'! //CHAR(0)&lt;/P&gt;&lt;P&gt;HOST_ADDRESS = get_host_address(%REF(HOST_NAME), %VAL(5))&lt;/P&gt;&lt;P&gt;IF (HOST_ADDRESS .NE. 0) THEN&lt;BR /&gt;PRINT 300, 'Host address = ',HOST_ADDRESS,&lt;BR /&gt;&amp;amp; 'Host name =', HOST_NAME&lt;BR /&gt;300 FORMAT(A20, Z8, A20, A40)&lt;BR /&gt;ELSE&lt;BR /&gt;PRINT *, 'Host name not resolved'&lt;BR /&gt;ENDIF&lt;/P&gt;&lt;P&gt;PRINT *,'Exiting program test4'&lt;/P&gt;&lt;P&gt;=================================================================================&lt;/P&gt;&lt;P&gt;TEST4C.C&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt;* Test C function to lookup host name and return IP address&lt;BR /&gt;* to be linked with TEST4.FOR&lt;BR /&gt;*/&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt;* INCLUDE FILES:&lt;BR /&gt;*/&lt;/P&gt;&lt;P&gt;#include &amp;lt;in.h&amp;gt; /* define internet related constants, */&lt;BR /&gt;/* functions, and structures */&lt;BR /&gt;#include &amp;lt;inet.h&amp;gt; /* define network address info */&lt;/P&gt;&lt;P&gt;#include &amp;lt;netdb.h&amp;gt; /* define network database library info */&lt;/P&gt;&lt;P&gt;#include &amp;lt;socket.h&amp;gt; /* define BSD 4.x socket api */&lt;BR /&gt;#include &amp;lt;stdio.h&amp;gt; /* define standard i/o functions */&lt;BR /&gt;#include &amp;lt;stdlib.h&amp;gt; /* define standard library functions */&lt;BR /&gt;#include &amp;lt;string.h&amp;gt; /* define string handling functions */&lt;/P&gt;&lt;P&gt;#include &amp;lt;unixio.h&amp;gt; /* define unix i/o */&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*&lt;BR /&gt;* NAMED CONSTANTS:&lt;BR /&gt;*/&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*&lt;BR /&gt;* FORWARD REFERENCES:&lt;BR /&gt;*/&lt;/P&gt;&lt;P&gt;struct hostent * gethname(char *, int );&lt;BR /&gt;int get_host_address(char *, int);&lt;/P&gt;&lt;P&gt;int get_host_address(char * name, int length)&lt;BR /&gt;{&lt;BR /&gt;printf("Entering get_host_address\nName = %s\nlength = %d\n", name, length);&lt;/P&gt;&lt;P&gt;struct hostent* my_host_ent;&lt;BR /&gt;struct in_addr my_in_addr;&lt;BR /&gt;int host_address;&lt;BR /&gt;char terminated_host_name[length+1];&lt;/P&gt;&lt;P&gt;strncpy(terminated_host_name, name, length);&lt;BR /&gt;printf("copied string\n");&lt;BR /&gt;terminated_host_name[length] = 0; //terminate the string&lt;/P&gt;&lt;P&gt;printf("terminated_host_name = %.80s\n", terminated_host_name);&lt;/P&gt;&lt;P&gt;my_host_ent=gethostbyname(terminated_host_name);&lt;/P&gt;&lt;P&gt;printf("my_host_ent = %d\n", my_host_ent);&lt;BR /&gt;if (my_host_ent)&lt;BR /&gt;{&lt;BR /&gt;printf("h-name = %.80s\n", my_host_ent-&amp;gt;h_name);&lt;BR /&gt;printf("h-length = %d\n", my_host_ent-&amp;gt;h_length);&lt;BR /&gt;printf("h_addr = %X\n", my_host_ent-&amp;gt;h_addr);&lt;BR /&gt;printf("h_addrtype = %X\n", my_host_ent-&amp;gt;h_addrtype);&lt;BR /&gt;memcpy( &amp;amp;my_in_addr, my_host_ent-&amp;gt;h_addr, sizeof(struct in_addr) );&lt;BR /&gt;printf("my_in_addr = %.80s\n",inet_ntoa(my_in_addr));&lt;BR /&gt;host_address = my_in_addr.S_un.S_addr;&lt;BR /&gt;printf("host_address = %X\n",host_address);&lt;BR /&gt;}&lt;BR /&gt;printf("Exiting get_host_address\n");&lt;/P&gt;&lt;P&gt;return(host_address);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;===================================================================================&lt;/P&gt;&lt;P&gt;TEST4.COM&lt;/P&gt;&lt;P&gt;$ ! build, link, run TEST4 - program to test bind lookup&lt;BR /&gt;$ CC/PREFIX=ALL TEST4C.C&lt;BR /&gt;$ FOR TEST4&lt;BR /&gt;$ LINK/MAP/FULL TEST4,TEST4C&lt;BR /&gt;$ RUN TEST4&lt;BR /&gt;$!&lt;BR /&gt;$ EXIT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 16:28:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6890290#M37647</guid>
      <dc:creator>Frank_Gribbin</dc:creator>
      <dc:date>2016-08-18T16:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN using TCPIP gethostbyname</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6890436#M37648</link>
      <description>&lt;P&gt;&amp;gt; [...] a C wrapper [...]&lt;/P&gt;&lt;P&gt;&amp;gt; HOST_ADDRESS = get_host_address(%REF(HOST_NAME), %VAL(5))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; That was pretty painful.&amp;nbsp; If you're going through all the work of&lt;BR /&gt;using a C wrapper, then it might as well be more convenient to use than&lt;BR /&gt;something with unnatural argument passing, and where the victim needs to&lt;BR /&gt;count characters.&amp;nbsp; (Nowadays, computers can do jobs like that.)&amp;nbsp; A more&lt;BR /&gt;(Fortran-)victim-friendly approach may be attached.&amp;nbsp; (It's always hard&lt;BR /&gt;to guess ahead of time which attachments will work in this (lame)&lt;BR /&gt;forum.)&lt;/P&gt;&lt;P&gt;alp $ cc ghbn_5c&lt;BR /&gt;alp $ fort ghbn_5f&lt;BR /&gt;alp $ link ghbn_5f, ghbn_5c&lt;BR /&gt;alp $ run ghbn_5f&lt;BR /&gt;Entering program test5&lt;BR /&gt;Entering get_host_address&lt;BR /&gt;Name = ftp.hpe.com&lt;BR /&gt;&lt;BR /&gt;length = 11&lt;BR /&gt;my_host_ent = 389040&lt;BR /&gt;h-name = ftp.hpe.com&lt;BR /&gt;h-length = 4&lt;BR /&gt;h_addr = 1246DC&lt;BR /&gt;h_addrtype = 2&lt;BR /&gt;my_in_addr = 216.237.214.19&lt;BR /&gt;host_address = 13D6EDD8&lt;BR /&gt;Exiting get_host_address&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Host address = 13D6EDD8 Host name =ftp.hpe.com&lt;BR /&gt;&lt;BR /&gt;Exiting program test5&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Note that I let the C function add the NUL terminator directly to the&lt;BR /&gt;Fortran name string.&amp;nbsp; It could make a local copy and NUL-terminate that,&lt;BR /&gt;but I was willing to trust the victim to leave room for it.&amp;nbsp; As usual,&lt;BR /&gt;many things are possible (and many of those don't make the victim count&lt;BR /&gt;characters).&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 21:08:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6890436#M37648</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2016-08-18T21:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN using TCPIP gethostbyname</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6890446#M37649</link>
      <description>&lt;P&gt;&amp;gt; [...] I'm sorry about being silent so long. [...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; I assumed that you had died.&lt;/P&gt;&lt;P&gt;&amp;gt; [...] I'd expected that the system would notify me when there were&lt;BR /&gt;&amp;gt; updates. [...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; You need to check the "Email me when someone replies" box when&lt;BR /&gt;posting, or, before you get logged out automatically, the Options menu&lt;BR /&gt;(in every posting) offers a "Subscribe" action.&lt;/P&gt;&lt;P&gt;&amp;gt; It seems I can't attach code examples, [...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;A href="http://community.hpe.com/t5/x/x/td-p/6878990" target="_blank"&gt;http://community.hpe.com/t5/x/x/td-p/6878990&lt;/A&gt;&lt;/P&gt;&lt;P&gt;As shown here, changing the file name to one of the approved (picture)&lt;BR /&gt;types seems to work, unless you expect your Web browser to show you the&lt;BR /&gt;result.&amp;nbsp; On the bright side, "Save Link As" lets you fix the name while&lt;BR /&gt;you save the file.&amp;nbsp; Of course, "I can't" is not a useful problem&lt;BR /&gt;description.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Back when I was still trying to use these forums from a Web browser&lt;BR /&gt;on VMS (Alpha), a Stream_LF file was required for attachment, but I've&lt;BR /&gt;mostly switched to Firefox on a Mac.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 21:28:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-using-tcpip-gethostbyname/m-p/6890446#M37649</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2016-08-18T21:28:34Z</dc:date>
    </item>
  </channel>
</rss>

