|
Any stream program can be started by InetD and run over Winsock. GUI and console applications can be initiated on the server, but cannot be controlled remotely. The program does not have to be network-aware. When InetD starts a stream program, it maps the program’s standard input, output and error handles to the socket connected to the remote user. Thus, as a program does its I/O using standard C-runtime calls ( like scanf(), printf(), etc.) or WIN32 calls ( like ReadFile(), WriteFile() ), they get redirected over connected Winsock session. Even a simple "hello world" program can be run via InetD over winsock. A user cannot interact with a console application launched by InetD. Use either Pragma TelnetServer, Fortress SSH Server, or TerminalServer to run a console application that requires user interaction.
Network-aware programs, which do I/O over a windows socket, need to use the environment variable passed, PRAGMASYS_INETD_SOCK , to obtain the socket handle that InetD has created for connecting the program to a remote user. InetD sets up this environment variable to the handle of a connected socket for a program. This socket handle is inherited by a program and is already accessible. So a network aware program only needs to add code similar to the following to make the program work:
sock = atoi ( getenv("PRAGMASYS_INETD_SOCK") ); recv ( sock, ...... ) ; send ( sock, ..... ) ;
Before a program can use the inherited handle, the the string value "CustomAppSupport" with a value of "yes" must be added to the product registry key
HKEY_LOCAL_MACHINE\SOFTWARE\PragmaSystems\TelnetD
Later versions can add this value by checking the box to enable "Support for legacy custom applications" on the General Settings page.
Programs run within a Pragma Fortress SSH Session cannot write directly to the socket, because the session requires the server encryption. Raw data to the client will cause the client to abort.
The environment variable PRAGMASYS_INETD_PID is available to view the Process ID of the InetD service.
|