On Mon, 16 May 2005 07:22:17 -0500, Mikael Wargh <[EMAIL PROTECTED]>
wrote:

>Hello you all almighty mainframers,
>I'm trying to automate heartbeat to one of our SMTP-servers. ICMP echo is
>not allowed.

I do type that type of heartbeat with REXX by just testing if I can make a
connection to the port. You may be looking for something more
comprehensive, but here's the function I use.

/* REXX ==============================================================*/
/* Function : Test connect to a TCPIP port                            */
/* Input: hostname port                                               */
/*        hostname - hostname to be tested                            */
/*        port     - Port to be tested.                               */
/*                                                                    */
/**********************************************************************/
parse arg server port
say testport(server, port)
exit

/**********************************************************************/
/* Sub: Attempt to connect to an IP port                              */
/**********************************************************************/
testport: procedure
server = arg(1)
port = arg(2)

func='Initialize'; call Socket func, 'HBEAT', 1  /* Get SocketSet */
if src \= 0 then signal socketError

func='Socket';s = Socket(func)       /* Get a socket */
if src \= 0 then signal socketError

call Socket 'Connect', s, 'AF_INET' port server  /* Try to connect */
if src = 0
 then retval = 'ACTIVE'
 else retval = 'INACTIVE'

if retval = 'ACTIVE'          /* If successful CONNECT, */
then do
  func='Close';call Socket func, s    /* Close the socket */
  if src \= 0 then signal socketError
end

func='Terminate';call Socket func, 'HBEAT'  /* Free the SocketSet */
if src \= 0 then signal socketError

return retval   /* Return to caller */

/**********************************************************************/
/* Sub: Call the REXX SOCKET function                                 */
/**********************************************************************/
/* Calling the real SOCKET function                                   */
socket: procedure expose src
  a0 = arg(1)
  a1 = arg(2)
  a2 = arg(3)
  a3 = arg(4)
  a4 = arg(5)
  a5 = arg(6)
  parse value 'SOCKET'(a0,a1,a2,a3,a4,a5) with src res
return res

/**********************************************************************/
/* Sub: Some unexpected error                                         */
/**********************************************************************/
socketError:
say 'Socket Error:' func ',rc=' src
call Socket 'Terminate', 'HBEAT'  /* Try to clean up SocketSet */
return '????'

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to