OpenVMS Source Code Demos
TCPIP$TCP_CLIENT_QIO_2014D
!========================================================================================================================
! title : tcpip$tcp_client_qio_2014d_103.inc
! author : Neil Rieck ( https://neilrieck.net )
! : (c) copyright 1999,2014 Neil Rieck
! : Waterloo, Ontario, Canada.
! created : 2014-08-15
! notes : this is an include file for HP-BASIC program "tcpip$tcp_client_qio_2014d_103.bas"
! history :
! ver who when what
! --- --- ------ --------------------------------------------------------------------------------------------------------
! 103 NSR 140814 1. original effort
! 104 NSR 140816 1. original effort with some new stuff
! 105 NSR 140817 1. more new stuff
!========================================================================================================================
!
! system references
!
%include "starlet" %from %library "sys$library:basic$starlet" ! system services
%include "$ssdef" %from %library "sys$library:basic$starlet" ! ss$
%include "$iodef" %from %library "sys$library:basic$starlet" ! io$
%include "$efndef" %from %library "sys$library:basic$starlet" ! efn$
%include "lib$routines" %from %library "sys$library:basic$starlet" ! lib$
%include "$libdef" %from %library "sys$library:basic$starlet" ! eg. lib$_normal
%include "$dscdef" %from %library "sys$library:basic$starlet" ! descriptor stuff
%include "$iledef" %from %library "sys$library:basic$starlet" ! ile3$ (Item List Entry 3 structures)
!~~~ %include "sys$common:[tcpware.include]ucx$inetdef.h" x candidate for conversion to BASIC
!~~~ %include "sys$library:ucx$inetdef.bas" x ucx defs (for tcpip < v5.0)
%include "sys$library:tcpip$inetdef.bas" ! tcpip defs (for tcpip >= v5.0)
!~~~ %include "$iosbdef" %from %library "sys$library:basic$starlet" x iosb$ (iosb structures)
!
! I need the following iosb to get around a limitation found in the BASIC version of starlet
! (the library definition of sys$qio requires a quad datatype for iosb)
!
! question : How did I know?
! answer : Hacking
! reference: https://neilrieck.net/docs/openvms_notes_hacking_starlet.html
!
record my_iosb_rec !
variant !
case ! vanilla
group a !
word iosb$w_status !
word iosb$w_bcnt !
long iosb$l_dev_depend !
end group !
case ! used in sys$getqui
group b !
long iosb$l_getxxi_status !
long iosb$l_reserved !
end group !
case ! used to satisfy the compiler
group c !
basic$quadword iosb$bqw_quad !
end group !
case !
group d !
word iosb$w_words(3) ! 0-3; easier to pass this on the stack
end group !
case !
group e !
quad iosb$q_quad ! easier to pass this on the stack
end group !
end variant !
end record !
!
record sc_rec ! socket characteristics
variant
case
group a
word sc$w_prot ! protocol
byte sc$b_type ! type
byte sc$b_af ! address family
end group !
case !
group b !
word sc$w_words(1) ! 0-1; easier to pass this on the stack
end group !
case
group c !
quad sc$q_quad !
end group !
end variant !
end record !
!
record my_itmlst2_rec ! item-list 2 descriptor
word il2$w_length ! length
word il2$w_type !
long il2$l_address !
end record !
!
! NCV ("NSR Connection Variables" or "Network Connection Variables")
!
! think object - although such a concept is not possible with this BASIC
!
record ncv_rec !
long tcp_ef !
long tcp_ef_state !
long tmr_ef !
long tmr_ef_state !
long mask !
long ip_address !
word tcp_port !
word vms_channel !
my_iosb_rec iosb ! i/o status block
sc_rec cscb ! connection socket characteristics buffer
variant ! serv_addr block
case !
group a !
SOCKADDRIN serv_addr ! server socket address from inet structure
end group !
case !
group b !
quad ccb$q_quad !
end group !
case !
end variant !
my_itmlst2_rec serv_itemlst !
end record !
!
! octet stuffing is more efficient than doing 32-bit math
! (if we ever go to IPv6 then it may be the only way forward)
!
record stuffer32_rec !
variant
case
group a
long long_offset00 ! octet 0 stuffs here
long fill !
end group
case
group b !
byte fill ! octet 1 stuffs here
long long_offset08 !
byte fill !
byte fill !
byte fill !
end group
case
group c !
byte fill !
byte fill !
long long_offset16 ! octet 2 stuffs here
byte fill !
byte fill !
end group
case
group d !
byte fill !
byte fill !
byte fill !
long long_offset24 ! octet 3 stuffs here
byte fill !
end group !
case
group e !
quad quad0 ! quad pulled from here
end group !
end variant
end record
!
! home brewed code
!
external long function htonl(long) ! host to network long
external long function htons(word) ! host to network short
external long function qtol(quad) ! quad to long
external long function parse_dest(string,string) !
external long function get_ef_bit_vector(long) ! required for used with SYS$WFLOR
!
!=========================================================================================================