Re: calling a 4GL routine from C socket server ?
Posted in 1997
Topics: Installation, Setup & Upgrades, Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
johnl@informix.com (Jonathan Leffler) writes: >On Tue, 25 Nov 1997, Kire Prostizenovski wrote: >> How would I be able to call a 4GL program from a C program. >In much the same way as you'd call a C program from a C program... >> We have a socket server process written in C, and would like to pass >> parameters to a 4GL program which will do it's thing and return the >> result. Can data be passed to the 4GL program through named pipes, or >> am I on the wrong track ? I snipped out a bunch of good stuff from Jonathan. What I did was pretty simple. I wrote a couple of easy C routines to handle reading and writing stdin and stdout. I imagine these are on the net somewhere as well. Then I leveraged off of the inetd daemon, and created a service for my .4ge. The inetd daemon listens to the port assigned to my service, and fires off the associated program (my .4ge) when someone opens the port. Then inetd handles the black magic of converting from sockets to stdio. No socket stuff at all in the 4GL. You can also easily telnet(1) to your port and watch it work. Worked like a champ. Debugging was trivial (run the .4ge all alone and feed it the appropriate inputs and watch the outputs). You can even use the debugger (though not in "net" mode, just standalone). To debug it, I wrote stub functions that used prompt and display. I would compile these into the program when I wanted to use the debugger and test it from the shell prompt. To "install" it, I just compiled in my other 4gl that called my C routines. The only detail was that because of the way I wrote my input and output routines, I had to pass a token (like *EOF*) to the .4ge instead of relying on a forced EOF from the inetd closing down the socket. But, that was just me. I'm sure there were other ways. I wouldn't suggest this technique for a zillion users, but it worked pretty well for me. I was doing some web stuff with it. Enjoy! -- Will Hartung - Rancho Santa Margarita. It's a dry heat. vfr750@netcom.com 1990 VFR750 - VFR=Very Red "Ho, HaHa, Dodge, Parry, Spin, HA! THRUST!" 1993 Explorer - Cage? Hell, it's a prison. -D. Duck