Nico Aragon <nico@nicoaragon.com> wrote:
> I'm a freelance programmer, used to work with Delphi
> (http://www.borland.com/delphi/), an object-oriented version of Pascal.
> A couple of weeks ago I was surprised to find that the language of my
> dreams already existed. I have been studying the primer and browsing the
> rest of the documentation and all seems very nice.
Glad to hear you like it. One problem is the huge amount of different
stuff that is included in Poplog. Most people need only a small subset
and finding the subset and the documentation on it can be difficult.
I have set up all the documentation in a form accessible to google at
the freepoplog web site:
http://www.cs.bham.ac.uk/research/poplog/
There's also a lot at this site, which adds quite a lot of useful
Pop-11 tools, including many developed by Steve Leach for his own
freelance software work.
http://www.poplog.org/
So if you give google a query with "poplog" as one of the keywords
you will often find an answer buried in one of those documentation files
or in an old news group message, or somehwere at www.poplog.org (which
is not just a mirror site, but adds a lot of useful extra stuff).
But it takes some practice learning to formulate the queries so as
to get good results from google. E.g. "poplog socket" gives some
relevant links.
> I don't mind if
> Pop-11 isn't a "mainstream language". I want to use the language that I
> consider the best.
Join the club :-)
> ...
> Anyway I need some kind of bridge to make Pop-11 work with existing web
> servers. I'm writing in Delphi an Apache module and an ISAPI dll to
> parse HTML, extract Pop-11 embedded snippets, send then to a stand-alone
> "Pop-11 daemon", and get a response from it. The Delphi part is easy for
> me. I've some doubts about the Pop-11 part of the
> communication, though. I hope you can help me.
>
> After thinking for a while (and a miserable failure trying pipes :-))
Pipes and "external" procedure calls have worked for many tasks in
Pop-11 on linux/unix. I know nothing about windows programming, however.
Sometimes if you can't do something directly from pop-11, you can write
a C program to do it, then link that in to pop-11. E.g. all the X window
interfaces in poplog work like that.
> I've decided to use sockets. The idea is that a socket is open between a
> Delphi webmodule and a Pop-11 process. Delphi webmodules are structures
> to handle an incoming server thread: Apache and IIS spawns several
> threads in a pool and Delphi creates a new webmodule to attend each. I
> only need to run Pop-11 as a typical multithreaded server. Pop-11 should
> fork a new process for every incoming connection. I will open a
> connection from every Delphi webmodule. There's a 1:1 relation. So from
> now on communication between a webmodule and a Pop-11 process handler
> will be very similar as between an user and the Pop-11 console.
There's information about unix/linux sockets in poplog in the online
file REF sockets, included in poplog, and available here:
http://www.cs.bham.ac.uk/research/poplog/doc/popref/sockets
Google also found this version
http://www.poplog.org/docs/popdocs/pop11/ref/sockets
which is very conveniently in html.
I don't think there is any documentation on the poplog socket mechanism
available under windows. However the version 15.53 poplog system for
windows available here
http://www.cs.bham.ac.uk/research/poplog/winpop/
includes a file windows_sockets.p, accessible separately here:
http://www.cs.bham.ac.uk/research/poplog/winpop/pop15-53/pop/lib/lib/windows_sockets.p
It states:
Purpose: Partial implementation of Unix-style Sockets for Windows
> Snippets come as a character string. Server must receive the string
> through the socket, and compile it or evaluate it and return some result
> or status code also through the socket. The socket remains open between
> conversations.
There is another option, which may or may not work for you. Pop-11 can
accept command line arguments. It is easy under unix to run pop11 with
a command to obey including starting up a saved image and running it
with arguments.
So you could use that method to run pop11 to process a string and then
print out some text in response your process can read the response and
use it. For that purpose you don't need to keep a socket open or a
process running. But you have the disadvantage of restarting pop-11
for each transaction. For relatively infrequent transactions that may
not be a heavy overhead.
It assumes that your language allows you to launch an arbitrary program
and to read back any textual output it produces (as pop-11 can).
> 2) I don't know if there is socket support for NT. Or how could I
> interface with winsock.h functions?.
See above. The windows_sockets.p file may help you.
> 3) I've found Pallantir. But I can't fully understand the server.p code in
> http://www.poplog.org/scripts/cvsweb/packages/palantir/sys/lib/
Never heard of palantir. Someone else will have to answer this
> Maybe because Palantir tries to do much more than I pretend ...
> ......I will try to change server.p to
> be simpler for me, but I would like to know if there is yet a little sample
> of a multithreaded server anywhere,
Riccardo Poli, who recently moved to Exeter University used to write
pop11 socket server code. I'll see if he has something he can offer.
The basic mechanism you need for a process that acts as a server is
a command to create a socket using sys_socket and if necessary
sys_socket_name to give the socket a local name.
Then just go into a loop:
use sysread to read input from the socket into some text buffer.
Then process the contents of the buffer, creating a string to be
sent back.
Then write the string to the socket
flush the output??
then possibly sleep for a while.
syswrite and sysread are standard pop-11 utilities, described in
REF sysio. There are lots more, e.g. sys_input_waiting, which reports
whether any input is waiting to be read on a device, and allows you
to cycle round several devices, unlike sysread, which hangs until there
is input.
I presume all those have variants that work with windows, though there
may be different argument options.
> Also I'm curious about the development status of PopLog. Is someone
> working maintaining and improving it?.
I'll answer that separately.
Aaron
|