|

REXX TCP/IP Sockets Source Code Download
this source code in text format (REXX
TCP/IP Code)
/*REXX*/ /* Edit macro to lookup the host name for an IP address */ Address ISPEXEC "ISREDIT MACRO NOPROCESS" /* We are an edit macro */ lastrc = RC If lastrc \= 0 Then Do ZEDLMSG = '''MACRO'' statement failed with RC = '||lastrc Call Setmsg End "ISREDIT (LINE,COL) = CURSOR" /* Get line/column cursor is on */ lastrc = RC If lastrc \= 0 Then Do ZEDLMSG = '''CURSOR'' statement failed with RC = '||lastrc Call Setmsg End "ISREDIT (DATA) = LINE "line" " /* Get a copy of same line */ lastrc = RC If lastrc \= 0 Then Do ZEDLMSG = '''LINE'' statement failed with RC = '||lastrc Call Setmsg End blank = Pos(' ',data,1) /* Find first blank on line */ If (blank = 0) | (blank > 16) Then Do ZEDLMSG = 'IP address not followed by a blank, ending execution.' Call Setmsg End If Verify(Substr(data,1,blank-1),'0123456789.') \= 0 Then Do ZEDLMSG = 'IP address contains invalid chars, ending execution.' Call Setmsg End data = Word(data,1) /* Strip out the IP address */ lastrc = Socket('INITIALIZE',Userid()) /* Connect to TCP/IP */ Parse Var lastrc tcprc subid maxdesc service If tcprc \= 0 Then Do ZEDLMSG = 'REXX SOCKET INITIALIZATION FAILED: '||tcprc Call Setmsg END lastrc = Socket('GETHOSTBYADDR',data) /* Go lookup host name */ Parse Var lastrc tcprc host If tcprc \= 0 Then Do ZEDLMSG = 'REXX SOCKET GETHOSTBYADDR FAILED: '||tcprc If tcprc = 2017 Then /* Treat this return code specially */ Do ZEDLMSG = 'Address was not found in DNS system. IP Addr.='data End Call Setmsg End lastrc = Socket('TERMINATE') /* Disconnect from TCP/IP */ Parse Var lastrc tcprc subid If tcprc \= 0 Then Do ZEDLMSG = 'REXX SOCKET Termination FAILED: '||tcprc Call Setmsg END ZEDLMSG = 'Host name obtained was: '||host /* Subroutine to write out a long form one-line message */ Setmsg: ZEDSMSG = '' "SETMSG MSG(ISRZ000)" lastrc = Socket('TERMINATE') Exit 4
|