Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using INETACP_FUNC$C_GETHOSTBYNAME using fortran- examples?

8 views
Skip to first unread message

Jamie Stallwood

unread,
Nov 13, 2001, 6:25:20 PM11/13/01
to
If anybody has any examples in FORTRAN of using the INETACP functions
with QIO in FORTRAN, I would receive them most gratefully! Especially
if they use the function above!

Thanks
Jamie P Stallwood

John Gemignani, Jr.

unread,
Nov 13, 2001, 9:52:12 PM11/13/01
to
Why are you asking the ACP for this information? You are better off calling
the DECC function to do the work.

-John

"Jamie Stallwood" <ja...@project76.co.uk> wrote in message
news:cta3vt88o4qklv44m...@4ax.com...

Tim Llewellyn

unread,
Nov 13, 2001, 10:47:58 PM11/13/01
to

If

http://www.openvms.compaq.com:8000/73FINAL/6529/6529pro_015.html#dev_func_dep_par_tab

doesn't help you then I am currently available.

best regards

--
Tim.Ll...@cableinet.co.uk

Standard disclaimer applies. My views in no way represent those of
my employers or service provider.

David Froble

unread,
Nov 14, 2001, 12:10:21 AM11/14/01
to
John Gemignani, Jr. wrote:

> Why are you asking the ACP for this information? You are better off
> calling the DECC function to do the work.
>
> -John


Only if you can get yourself to work in 'C'.


> "Jamie Stallwood" <ja...@project76.co.uk> wrote in message
news:cta3vt88o4qklv44m...@4ax.com...
>

>
>> If anybody has any examples in FORTRAN of using the INETACP
>> functions with QIO in FORTRAN, I would receive them most
>> gratefully! Especially if they use the function above!
>>
>> Thanks Jamie P Stallwood

Been way too many years since I did Fortran. I've implemented some
socket communications in Basic using the system service interface. If
you feel that you can benefit from some of this, I can send you some.

Note that it can get rather interesting, and I found at least one place
where the manual had things backwards. IO$_SETMODE and IO$_SETMODE are
both usable for the same action. One requires privs, the other doesn't.
The damn manual had them backwards, at least the 'old' manual that I
bought. It appears that the 'new' manual, (must have come out the day
after I bought one) only mentions the one that doesn't need privs.

Dave, still learning.

--
David Froble Tel: 724-529-0450
Dave Froble Enterprises, Inc. Fax: 724-529-0596
DFE Ultralights, Inc. E-Mail: da...@tsoft-inc.com
T-Soft, Inc. 170 Grimplin Road Vanderbilt, PA 15486

Phil Howell

unread,
Nov 14, 2001, 2:44:23 AM11/14/01
to

"David Froble" <da...@tsoft-inc.com> wrote in message
news:3BF1FCB...@tsoft-inc.com...

> John Gemignani, Jr. wrote:
>
> > Why are you asking the ACP for this information? You are better off
> > calling the DECC function to do the work.
> >
> > -John
>
>
> Only if you can get yourself to work in 'C'.
>
>
> > "Jamie Stallwood" <ja...@project76.co.uk> wrote in message
> news:cta3vt88o4qklv44m...@4ax.com...
> >
>
> >
> >> If anybody has any examples in FORTRAN of using the INETACP
> >> functions with QIO in FORTRAN, I would receive them most
> >> gratefully! Especially if they use the function above!
> >>
> >> Thanks Jamie P Stallwood
>
> Been way too many years since I did Fortran. I've implemented some
> socket communications in Basic using the system service interface. If
> you feel that you can benefit from some of this, I can send you some.
>
> Note that it can get rather interesting, and I found at least one place
> where the manual had things backwards. IO$_SETMODE and IO$_SETMODE are
do we have to parse one of these as io$_sensemode?

Carl Perkins

unread,
Nov 14, 2001, 1:23:00 PM11/14/01
to
David Froble <da...@tsoft-inc.com> writes...

}John Gemignani, Jr. wrote:
}
} > Why are you asking the ACP for this information? You are better off
} > calling the DECC function to do the work.
} >
} > -John
}
}Only if you can get yourself to work in 'C'.

This is VMS. You can call the DECC functions from any language.

--- Carl

Hiroyuki Tanaka

unread,
Nov 14, 2001, 3:36:31 PM11/14/01
to
PROGRAM DRIVER
IMPLICIT NONE
INTEGER*4 UCX_GETHOSTBYNAME
INTEGER*4 IP_ADDR !*** Reverse byte order ***
INTEGER*4 STATUS
CHARACTER*(80) HOSTNAME
HOSTNAME='TEST' ! IP = 10.1.1.1
STATUS = UCX_GETHOSTBYNAME(IP_ADDR, HOSTNAME)
WRITE (6,'(1X,Z8.8)') IP_ADDR ! 0101010A
STOP
END

INTEGER*4 FUNCTION UCX_GETHOSTBYNAME(IP_ADDR, HOSTNAME)
IMPLICIT NONE
INCLUDE '($IODEF)'
INCLUDE '($SSDEF)'
INCLUDE '($SYSSRVNAM)'
PARAMETER INET_DEVNAME = 'UCX$DEVICE:'
INCLUDE 'SYS$LIBRARY:UCX$INETDEF.FOR'
INTEGER*2 CHANNEL
INTEGER*2 IHOST
INTEGER*4 IP_ADDR
INTEGER*4 STATUS
INTEGER*4 RETLEN
CHARACTER*(*) HOSTNAME
STRUCTURE /IOSBLK/
INTEGER*2 STATUS
INTEGER*2 SIZE
INTEGER*4 RETADR
END STRUCTURE
STRUCTURE /ADDR_BUFF/
UNION
MAP
INTEGER*4 IP_ADDR
INTEGER*4 %FILL(7)
END MAP
MAP
CHARACTER*32 STRING
END MAP
END UNION
END STRUCTURE
STRUCTURE /ACPCOMMAND/
UNION
MAP
INTEGER*1 SUBFUNCTION
INTEGER*1 CALLCODE
INTEGER*2 %FILL
END MAP
MAP
CHARACTER*4 STRING
END MAP
END UNION
END STRUCTURE
RECORD /IOSBLK/ IOSB
RECORD /ACPCOMMAND/ COMM
RECORD /ADDR_BUFF/ ADDR_BUFF
!
IP_ADDR = 0
!
! Setup the INETACP command to do a GETHOSTBYNAME and
! return an IP address as an integer longword
!
COMM.SUBFUNCTION = INETACP_FUNC$C_GETHOSTBYNAME
COMM.CALLCODE = INETACP$C_TRANS
!
! Assign a channel to the internet device.
!
STATUS = SYS$ASSIGN(INET_DEVNAME,CHANNEL,,)
!
IF (.NOT. STATUS) THEN
UCX_GETHOSTBYNAME = STATUS
RETURN
END IF
!
CALL STR$TRIM(HOSTNAME, HOSTNAME, IHOST)
!
STATUS = SYS$QIOW(,
- %VAL(CHANNEL),
- %VAL(IO$_ACPCONTROL),
- IOSB,
- ,
- ,
- %DESCR(COMM.STRING), ! P1 = ACP command
- %DESCR(HOSTNAME(1:IHOST)), ! P2 = host name to lookup
- RETLEN, ! P3 = length of returned
- %DESCR(ADDR_BUFF.STRING), ! P4 = return address
- ,)
!
! Close the channel to the INET device
!
CALL SYS$DASSGN(CHANNEL)
!
! Check the status and the IOSB.STATUS block
!
IF (.NOT. STATUS) THEN
UCX_GETHOSTBYNAME = STATUS
RETURN
END IF

IF (.NOT. IOSB.STATUS) THEN
UCX_GETHOSTBYNAME = IOSB.STATUS
RETURN
END IF
!
IP_ADDR = ADDR_BUFF.IP_ADDR
UCX_GETHOSTBYNAME = SS$_NORMAL
!
RETURN
END

I think this is what you want.

I just wish I could get it to work in C.

Larry Kilgallen

unread,
Nov 14, 2001, 6:02:24 PM11/14/01
to

There might be a question regarding "support". If the DECC function
has a double dollar sign in the linker name, or is not documented,
then they reserve the right to change it's behaviour for some future
version so long as it still works with code from the C compiler.

Tim Llewellyn

unread,
Nov 14, 2001, 10:41:19 PM11/14/01
to

David Froble wrote:
>
> John Gemignani, Jr. wrote:
>
> > Why are you asking the ACP for this information? You are better off
> > calling the DECC function to do the work.
> >
> > -John
>
> Only if you can get yourself to work in 'C'.

Hey Dave, this is VMS, you can call C routines from Fortran, I'm sure
that is what John
meant. OK, you might have to mess with %VAL and %REF and friends.

David Froble

unread,
Nov 15, 2001, 12:48:49 AM11/15/01
to
Tim Llewellyn wrote:

>
> David Froble wrote:
>
>>John Gemignani, Jr. wrote:
>>
>> > Why are you asking the ACP for this information? You are better off
>> > calling the DECC function to do the work.
>> >
>> > -John
>>
>>Only if you can get yourself to work in 'C'.
>>
>
> Hey Dave, this is VMS, you can call C routines from Fortran, I'm sure
> that is what John
> meant. OK, you might have to mess with %VAL and %REF and friends.
>

Yes, that's true. But, using the C routines from other than C has to be
harder than working in C. I just didn't have the courage to go there.
I've done system programming from time to time, and using the RTL
routines and system services is something I'm comfortable with. My real
problem was learning TCP/IP and socket programming. It was fun, and I'm
now keeping a lookout for other places I can use it. What I haven't
done yet is any type of simultaneous processing of messages on the
server side.

A bit of a question for those who have had to address such. I've read
about passing messages to other processes for handling. I could imagine
threads being used in some applications. What have those who have had
to do simultaneous processing of messages found to be good methods?

Dave

Jamie Stallwood

unread,
Nov 15, 2001, 4:50:25 AM11/15/01
to
Hiroyuki...@excite.co.jp (Hiroyuki Tanaka) wrote in message news:<68cfa44d.01111...@posting.google.com>...
> PROGRAM DRIVER
> IMPLICIT NONE

Thanks for that, I'll give it a jolly good go. And thanks for the
lievly discussion everyone, it always cheers me up... :)

Carl Perkins

unread,
Nov 15, 2001, 10:42:00 AM11/15/01
to
David Froble <da...@tsoft-inc.com> writes...

}What I haven't
}done yet is any type of simultaneous processing of messages on the
}server side.
}
}A bit of a question for those who have had to address such. I've read
}about passing messages to other processes for handling. I could imagine
}threads being used in some applications. What have those who have had
}to do simultaneous processing of messages found to be good methods?
}
}Dave

I think the easiest method may be to do it all in one process and one
thread using asynchronous QIOs and ASTs. When any QIO completes, it
gathers the relevant data, puts it in a queue (one for each of read
completion, write completion, or new connection, for example), and does
a SYS$WAKE. When the process wakes up, it pulls things off queues and
processes them. When there isn't anthing left in any queue it does a
SYS$HIBER. You can handle a moderately large number of connections that
don't shift too much data, or do too much processing of it, this way all
in one process (watching out for your process quotas).

There are examples of parts of this in various places (such as in
SYS$SYSROOT:[SYSHLP.EXAMPLES.TCPIP...]) but they are pretty much all
in C. Perhaps the best example is SYS$EXAMPLES:DB_SERVER.C. I found
that translating it to Fortran wasn't very difficult (although I do know
C, which probably makes it considerably easier). It is a server that
processes IO over multiple connections via DECnet. There is some sort of
example in Fortran called SYS$EXAMPLES:OSIT$ECHO.FOR which does something
vaguely similar (I didn't look very closely, but it doesn't seem to be
as complete an example as DB_SERVER.C is) also over DECnet. All the TCPIP
examples seem to use only QIOW, which is not so nice.

Then again I've never actually used the multiple processes or multiple
threads methods so I can't say that if methods are, or are not, actually
significantly more difficult to use.

--- Carl

Tim Llewellyn

unread,
Nov 15, 2001, 1:18:28 PM11/15/01
to

Carl Perkins wrote:
>
> David Froble <da...@tsoft-inc.com> writes...
> }What I haven't
> }done yet is any type of simultaneous processing of messages on the
> }server side.
> }
> }A bit of a question for those who have had to address such. I've read
> }about passing messages to other processes for handling. I could imagine
> }threads being used in some applications. What have those who have had
> }to do simultaneous processing of messages found to be good methods?
> }
> }Dave
>
> I think the easiest method may be to do it all in one process and one
> thread using asynchronous QIOs and ASTs. When any QIO completes, it
> gathers the relevant data, puts it in a queue (one for each of read
> completion, write completion, or new connection, for example), and does
> a SYS$WAKE. When the process wakes up, it pulls things off queues and
> processes them. When there isn't anthing left in any queue it does a
> SYS$HIBER. You can handle a moderately large number of connections that
> don't shift too much data, or do too much processing of it, this way all
> in one process (watching out for your process quotas).

I too have found this approach to work well.

>
> There are examples of parts of this in various places (such as in
> SYS$SYSROOT:[SYSHLP.EXAMPLES.TCPIP...]) but they are pretty much all
> in C. Perhaps the best example is SYS$EXAMPLES:DB_SERVER.C. I found
> that translating it to Fortran wasn't very difficult (although I do know

You too!

> C, which probably makes it considerably easier). It is a server that
> processes IO over multiple connections via DECnet. There is some sort of
> example in Fortran called SYS$EXAMPLES:OSIT$ECHO.FOR which does something
> vaguely similar (I didn't look very closely, but it doesn't seem to be
> as complete an example as DB_SERVER.C is) also over DECnet. All the TCPIP
> examples seem to use only QIOW, which is not so nice.

>
> Then again I've never actually used the multiple processes or multiple
> threads methods so I can't say that if methods are, or are not, actually
> significantly more difficult to use.
>

The multiple processes approach requires more context switches (save
process state,
load new process state) but with modern hardware this may not be an
issue unless
you are pushing the capabilities of current top-of-the-range hardware.
Removing
this overhead is, I suppose, one reason why threads libraries were
developed, the
other being to reduce implementation errors using QIO's, AST's, event
flags and
linked lists, which presumably is what the thread libraries do
internally.

regards

> --- Carl

Paul Repacholi

unread,
Nov 15, 2001, 1:28:49 PM11/15/01
to
ca...@gerg.tamu.edu (Carl Perkins) writes:

> Then again I've never actually used the multiple processes or multiple
> threads methods so I can't say that if methods are, or are not, actually
> significantly more difficult to use.

The WASD web server will provide a nice example to study. And serve the
odd page or two as well :)

--
Paul Repacholi 1 Crescent Rd.,
+61 (08) 9257-1001 Kalamunda.
West Australia 6076
Raw, Cooked or Well-done, it's all half baked.
EPIC, The Architecture of the future, always has been, always will be.

John Gemignani, Jr.

unread,
Nov 15, 2001, 2:24:07 PM11/15/01
to
I assume that the $QIO that is coded up to INETACP will also include %VAL
and %REF's, right? My take is from the ACP's view. I don't think it's a
good idea to make the ACP call the bind code to do hostname translations for
you. Now, when I get a chance to redesign the ACP, perhaps it won't be so
bad...

-John

message news:3BF33871...@cableinet.co.uk...

Richard Maher

unread,
Nov 17, 2001, 12:34:59 PM11/17/01
to
Hi,

inetacp$c_trans is probaly what you were looking for and is the best way
that I know of to xlate ip addresses and names. (Maybe someone should update
the documentation to say that that's what it does?) But in case you wanted
the entire hostent structure I've included the following example.

It's not fortran but it does unravel the hostent structure to the best of my
knowledge.

Regards Richard Maher


The way I see it is:-

. host_name is an offset to a null terminated string
. host_aliases is an offset to a list of offsets to null terminated
strings.
The offset list being terminated by a null.
. host_addresses is an offset to an offset to a list of addresses. The list
terminated when the pointer is >= the addresss of the first
offset.

Because, to some degree, Compaq has been churlishly unilateral in it's
approach
to IPv6 and TCPware/Multinet(Process Software) It could be argued that there
is
a disadvantage to a network software developer in supporting AF_INET6
addresses.

A couple of observations with Solaris.

1) If a hostname has more than one address then the address won't back
xlate.
IE: If you enter ascii 1.2.3.4 It results in "No such node".
2) The node adresses are delimted by nulls or longword zeros wheres on UCX
(for at least the hosts file) they're not.


identification division.
program-id. get_host.
environment division.
configuration section.
special-names.

class a_valid_nodename is "A" thru "Z",
"a" thru "z",
"0" thru "9",
".", "-","_",
"/", " ","$".
data division.
working-storage section.
01 ucx$c_af_inet pic 9(9) comp value external
ucx$c_af_inet.
01 gethostbyname pic 9(9) comp value external
gethostbyname.
01 io$_acpcontrol pic 9(9) comp value external
io$_acpcontrol.
01 ss$_endoffile pic 9(9) comp value external
ss$_endoffile.
01 ss$_badparam pic 9(9) comp value external
ss$_badparam.
01 ss$_normal pic 9(9) comp value external ss$_normal.
01 sys_status pic 9(9) comp.
*
01 iosb.
03 cond_val pic 9(4) comp.
03 pic x(6).
*
01 inet_chan pic 9(4) comp.
01 eof pic x value "N".
01 in_name pic x(50).
01 in_len pic 9(4) comp.
01 out_len pic 9(4) comp.
01 out_string.
03 host_name pic 9(9) comp.
03 host_aliases pic 9(9) comp.
03 host_addrtype pic 9(9) comp.
03 host_addrlen pic 9(9) comp.
03 host_addresses pic 9(9) comp.
03 pic x(1004).
01 item_start pic 9(9) comp.
01 item_len pic 9(9) comp.
01 offset_string.
03 ra_1 pic x.
03 ra_2 pic x.
03 ra_3 pic x.
03 ra_4 pic x.
01 item_offset redefines
offset_string pic 9(9) comp.
01 rem_addr pic x(32).
01 rem_addr_len pic 9(4) comp.
*
procedure division.
kick_off section.
00.
call "sys$assign"
using by descriptor "_bg:"
by reference inet_chan
by value 0, 0, 0
giving sys_status.
if sys_status not = ss$_normal call "lib$stop" using by value
sys_status.

display "Enter Nodename: " line 1 column 1 erase screen no advancing.
accept in_name reversed bold protected at end move "Y" to eof.

perform dump_host until eof = "Y".
*
fini.
call "sys$dassgn" using by value inet_chan giving sys_status.
if sys_status not = ss$_normal call "lib$stop" using by value
sys_status.

stop run.
*
dump_host section.
00.
if in_name = spaces go to fini.

if in_name is not a_valid_nodename
display "Illegal character(s) entered"
go to fini.

call "str$trim"
using by descriptor in_name, in_name
by reference in_len
giving sys_status.
if sys_status not = ss$_normal call "lib$stop" using by value
sys_status.

call "sys$qiow"
using by value 0, inet_chan, io$_acpcontrol
by reference iosb
by value 0,0
by descriptor gethostbyname, in_name(1:in_len)
by reference out_len
by descriptor out_string
by value 0,0
giving sys_status.

if sys_status = ss$_normal move cond_val to sys_status.
evaluate sys_status
when ss$_normal perform format_display
when ss$_badparam display "Increase the size of Out_String"
when ss$_endoffile display "Unknown Node"
when other call "lib$stop" using by value sys_status
end-evaluate.
*
fini.
display "Enter Nodename: " no advancing.
accept in_name reversed bold protected at end move "Y" to eof.
*
format_display section.
00.
if (host_addrtype not = ucx$c_af_inet)
or (host_addrlen not = 4 )
display "Unknown address type/len"
display "Can't handle af_inet6"
go to fini.
*+
* Get official host name
*-
if host_name not = zeros
add 1, host_name giving item_start
move zeros to item_len
inspect out_string(item_start:(out_len - host_name))
tallying item_len for characters before initial low-value
display 'Host Name is "', out_string(item_start:item_len), '"'.
*+
* Dump aliases
*-
if host_aliases not = zeros
add 1, host_aliases giving item_start
perform until item_start >= out_len
move out_string(item_start:4) to offset_string
if item_offset = zeros
move out_len to item_start
else
move zeros to item_len
inspect out_string((item_offset + 1):(out_len -
item_offset))
tallying item_len for characters before initial
low-value
display 'Alias is "', out_string((item_offset +
1):item_len), '"'
add 4 to item_start
end-if
end-perform.
*+
* Dump Addresses
*-
if host_addresses not = zeros
move out_string((host_addresses + 1):4) to offset_string
add 1, item_offset giving item_start
perform until item_start >= host_addresses
move out_string(item_start:4) to offset_string
if item_offset not = zeros
call "sys$fao"
using by descriptor "Trying address:-
!@UB.!@UB.!@UB.!@UB"
by reference rem_addr_len
by descriptor rem_addr
by reference ra_1, ra_2, ra_3, ra_4
giving sys_status
if sys_status not = ss$_normal
call "lib$stop" using by value sys_status
end-if
display rem_addr(1:rem_addr_len)
end-if
add 4 to item_start
end-perform.
*
fini.
*
end program get_host.

;MACRO definition file

.title get_host_def

.library /inet/

$inetsymdef GLOBAL
$inetacpfsymdef
$inetacpsymdef

gethostbyname == <inetacp$c_hostent_offset * 256 +
inetacp_func$c_gethostbyname>

.end


Jamie Stallwood <ja...@project76.co.uk> wrote in message
news:cta3vt88o4qklv44m...@4ax.com...

Hoff Hoffman

unread,
Nov 27, 2001, 2:35:47 PM11/27/01
to
In article <3BF1FCB...@tsoft-inc.com>, David Froble <da...@tsoft-inc.com> writes:

:John Gemignani, Jr. wrote:
:
: > Why are you asking the ACP for this information? You are better off
: > calling the DECC function to do the work.
: >
: > -John
:
:
:Only if you can get yourself to work in 'C'.
:
:
: > "Jamie Stallwood" <ja...@project76.co.uk> wrote in message
:news:cta3vt88o4qklv44m...@4ax.com...
: >
:
: >
: >> If anybody has any examples in FORTRAN of using the INETACP
: >> functions with QIO in FORTRAN, I would receive them most
: >> gratefully! Especially if they use the function above!
: >>
: >> Thanks Jamie P Stallwood
:
:Been way too many years since I did Fortran. I've implemented some
:socket communications in Basic using the system service interface. ...


TCPIP$EXAMPLES:TCPIP$TCP_CLIENT_QIO.MAR


---------------------------- #include <rtfaq.h> -----------------------------
For additional, please see the OpenVMS FAQ -- www.openvms.compaq.com
--------------------------- pure personal opinion ---------------------------
Hoff (Stephen) Hoffman OpenVMS Engineering hoffman#xdelta.zko.dec.com

0 new messages