InetD Services

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 or Terminal Server 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, ..... ) ;

The environment variable PRAGMASYS_INETD_PID is available to view the Process ID for inetdsrv.exe.

 

See Also:
The InetD Service
Configure InetD