× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I don't see a "return" statement in your "else" block. How would the program end?

-Nathan


________________________________
From: Pete Helgren <pete@xxxxxxxxxx>
To: RPG Midrange Discussion <rpg400-l@xxxxxxxxxxxx>
Sent: Wednesday, June 22, 2011 11:42 AM
Subject: Differing results in calling same program from different environments

I have an ILE RPG program is pretty simple: It checks to see if the port
at a certain host is online or not. It was written to demonstrate how to
call an RPG program from Java.  It works fine  when called from Java.  I
wrote an ILE RPG 5250 program that calls the same program (CHK_PORT). 
It works well in that ILE RPG program as well.  So I am now using it in
a CGIDEV2 program and it works well if the host/port is online but if
the host is offline, the call times out rather than returns which causes
the CGIDEV2 program to fail.

The CHK_PORT program is based on some code from Scott Klements Sockets
programming tutorial (I think).  The challenge in writing the program in
the first place was coding for the the failure of the connection when
the host or port was offline.  I solved it using the following code:

      C*************************************************
      C* Connect to the requested host
      C*************************************************
      C/FREE
            init_signals();

            alarm(5);
            if connect(sock: p_connto: addrlen) < 0;
                  msg = 'unable to connect to server!';
                //  dsply  msg;
                  callp close(sock);
                  alarm(0);
                  port_status = '0';
                  return;
            else;
                  msg = 'Host is online!';
                  port_status = '1';
                  // dsply msg;
            endif;
      /end-free

Again, the code works great when I call it from Java or from the ILE RPG
5250 program I wrote, but the CGIDEV2 program which calls the program
never seems to time out when the connection fails.  This *seems* like an
activation group issue (?) but I can't quite figure out why an offline
host/port causes it to fail ONLY in the CGIDEV2 program call.  In fact,
the code used in the CGIDEV2 program was a cut and paste from the 5250
program with slight modifications to accommodate the CGIDEV2  methods of
reading/writing to the output.

Any ideas on where to start tracking down the issue?


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.