From: Jonathan F. <jf...@ac...> - 2003-04-22 19:02:32
|
Hello This message describes a prototype socket interface to the TeX daemon. Refer to Lutz, Programming Python (2nd edition) for details and for some examples to follow. The Python Reference Manual is probably just as good, but I like bound printed pages. * Overview To use the TeX daemon, open a connection to the server socket, and send to it a suitable string. The TeX daemon will then process the string. If required, it will send dvi back to the client. At the end of the transaction, the connection is closed. * Opening and closing the socket Client will open connection to server, as in Lutz p528. Client will send the whole string to the server. Client will use shutdown(1) to disallow further sends. Server will read the whole string. Server will use TeX to process the string. Server will read resulting dvi. Server will process dvi as requested by client's string. * Suitable strings A suitable string consists of 3 lines, followed by TeX code. suitable_string = protocol + tex_format + forward + tex_code protocol = 'prototype 001\n' tex_format = 'plain\n' tex_format = 'latex\n' tex_format = '/home/jfine/work/paper03.fmt\n' tex_code = r'''any valid \TeX\ code for the chosen format. ''' forward = command + options + '\n' Some sample commands forward = 'return\n' # send dvi back to client forward = 'preview\n' # send dvi to a previewer forward = 'write /tmp/pic_1234.dvi' # write to file * The forward interface The TeX daemon will split the forward line, look up the command in a dictionary, and call the resulting value, with the options and the dvi as arguments. * Notes I've written this to record and share my thoughts. There ought to be enough detail here to write test code. It also ought to be possible to fairly easily write a dummy server (that contains the framework into which the real live TeX daemon code can be added). It may be that SocketServer provides a suitable starting point. Jonathan |