Consultor Eletrônico



Kbase P20453: Error 513 or 3268 when trying to use WAIT-FOR in batch mode
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   15/10/2008
Status: Unverified

FACT(s) (Environment):

Progress 9.X
OpenEdge 10.0A
OpenEdge 10.0B

SYMPTOM(s):

Trying to use WAIT-FOR in batch mode get one of the errors:


** Attempt to read with no current input (513)

Cannot WAIT-FOR input from a stream. (3268)

CAUSE:


Normally, a program in batch mode is not event driven so a WAIT-FOR statement was not allowed. This rule has changed in version 9 since batch mode can now manage socket events.

WAIT-FOR statement in batch-mode currently supports only 3 events (PROCEDURE-COMPLETE,READ-RESPONSE and CONNECT).


FIX:

In order to be able to build an event driven batch process, it can be created a 'dummy' socket server object as in the below example.
It might be that a specific port number the server tries to use will be in use, so the program will scan the first 100 port numbers above port 3000 to find the first available.

/*-------------------------------*/
DEFINE VARIABLE lListening AS LOGICAL NO-UNDO INIT NO.
DEFINE VARIABLE StopItLogicalFlag AS LOGICAL NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE hServer AS HANDLE NO-UNDO.CREATE SERVER-SOCKET hServer.
REPEAT WHILE i < 100 AND NOT lListening:
lListening = hServer:ENABLE-CONNECTIONS('-S ' + STRING(3000 + i)) NO-ERROR.
IF NOT lListening THEN
i = i + 1.
END.
IF NOT lListening THEN
RETURN ERROR 'All scanned ports are in use. Use another port range'.DO WHILE NOT StopItLogicalFlag:
WAIT-FOR CONNECT OF hServer PAUSE 0.
END. /*-------------------------------*/ Note that the PAUSE 0 does not lead to high CPU usage => 0%. Tests in GUI show that there is actually a delay of about 15 milliseconds, which then leads to about 60 interruptions per seconds. At last, the socket server object can be used to receive a 'DoQuit' message to exit the program a nice way.