I have many M-Code routines provided by the supplier as part of a much larger product that uses READ and WRITE directly to interact with the current device. I can not change this code. I want to wrap some of these routines in a system where I can provide input and output capture interactively.
This is currently implemented by opening a TCP connection to the remote host and making it the current device. READ and WRITE really connected to the socket. This is quite inconvenient, since it requires that a separate service that listens for a TCP socket is configured and coordinated with a local job for the entire process to work. I also have to turn off the insolence and skip the buffering, or the connection becomes latent or closed. (for example, the TCP option OPEN /SEN=1 aka +Q ). Unfortunately, this leads to many 1-byte TCP segments and is also very inefficient.
I would rather manage all interactions through one process. Ideally, I could call READ , WRITE , and other functions on the current device trigger some M-codes or callbacks in the Caché Callin C or user extension module to provide the required functions on the rear panel. Thus, I can manage IO on my own terms without the need for coordination between processes. I could not find an entry point to set this, though.
Is there such a thing as a user device in Caché?
For UNIX hosts, there is a way to use an existing file descriptor as a device, which may be useful, but it doesn't seem to be implemented on Windows.
One thing I considered is to create a new process, redirect Windows STDIN and STDOUT using SetStdHandle to the channels I control from the same process, use Callin to connect to Caché and let it use the default device, which should be STDIN and STDOUT . Does anyone know if this really works?
source share