Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f95fd5871 | ||
|
|
59955b8412 |
@@ -0,0 +1,66 @@
|
|||||||
|
H* When I discovered how the mill communicates with some of the larger clients via ftp I was
|
||||||
|
H* interested to find out what TCP/IP capabilites were availible for RPG. As it turns out; with
|
||||||
|
H* a lot of painful method prototyping the entire C TCP/IP library is availible for use within
|
||||||
|
H* an RPGLE program. That being said, I am sure that you could also use Java's implementation
|
||||||
|
H* but in this environment the C methods are noticeably faster since there is no JVM overhead.
|
||||||
|
|
||||||
|
H* This program makes use of the IBM supplied TCP/IP API already on this system written in C.
|
||||||
|
H* The majority of the program is method prototypes in the D specs which would be better off
|
||||||
|
H* placed in their own source member; a "header file" so to speak; that could be imported with
|
||||||
|
H* the "/copy" compiler directive. Assuming something like this becomes a regular task.
|
||||||
|
|
||||||
|
H* MAY 20, 2013 - As of today this program preforms a DNS lookup on 'www.google.com' and
|
||||||
|
H* displays the IP address found.
|
||||||
|
|
||||||
|
H DFTACTGRP(*NO) ACTGRP(*NEW)
|
||||||
|
|
||||||
|
D INADDR_NONE C CONST(4294967295)
|
||||||
|
|
||||||
|
D gethostbyname PR * extproc('gethostbyname')
|
||||||
|
D host_name * value options(*string)
|
||||||
|
|
||||||
|
D getservbyname PR * ExtProc('getservbyname')
|
||||||
|
D service_name * value options(*string)
|
||||||
|
D protocol_name * value options(*string)
|
||||||
|
|
||||||
|
D inet_addr PR 10U 0 ExtProc('inet_addr')
|
||||||
|
D address_str * value options(*string)
|
||||||
|
|
||||||
|
D inet_ntoa PR * ExtProc('inet_ntoa')
|
||||||
|
D internet_addr 10U 0 value
|
||||||
|
|
||||||
|
D p_hostent S *
|
||||||
|
D hostent DS based(p_hostent)
|
||||||
|
D h_name *
|
||||||
|
D h_aliases *
|
||||||
|
D h_addrtype 10I 0
|
||||||
|
D h_length 10I 0
|
||||||
|
D h_addr_list *
|
||||||
|
D p_h_addr S * based(h_addr_list)
|
||||||
|
D h_addr S 10U 0 based(p_h_addr)
|
||||||
|
|
||||||
|
D p_servent S *
|
||||||
|
D servent DS based(p_servent)
|
||||||
|
D s_name *
|
||||||
|
D s_aliases *
|
||||||
|
D s_port 10I 0
|
||||||
|
D s_proto *
|
||||||
|
|
||||||
|
D IP S 10U 0
|
||||||
|
D msg S 50A
|
||||||
|
|
||||||
|
/free
|
||||||
|
//Attempt to resolve IP address
|
||||||
|
p_hostent = gethostbyname('www.google.com');
|
||||||
|
|
||||||
|
//Print IP if successful
|
||||||
|
if not (p_hostent = *NULL);
|
||||||
|
IP = h_addr;
|
||||||
|
msg = 'DNS lookup successful! IP = ' + %str(inet_ntoa(IP));
|
||||||
|
|
||||||
|
dsply msg;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
*inlr = *on;
|
||||||
|
return;
|
||||||
|
/end-free
|
||||||
Reference in New Issue
Block a user