Hi,
I'm trying to figure out how to implement a XML-RPC server that
is called by xinetd i.s.o. listening on a TCP socket itself.
I already have implemented a stand-alone XML-RPC server using
SimpleXMLRPCServer, but I now want something similar, that is
started via xinetd (i.e. reading/writing via stdin/stdout).
Any hints or code examples?
Thanks,
--
-- Jos Vos <jo*@xos.nl>
-- X/OS Experts in Open Systems BV | Phone: +31 20 6938364
-- Amsterdam, The Netherlands | Fax: +31 20 6948204 12 3205
Jos Vos wrote: Hi,
I'm trying to figure out how to implement a XML-RPC server that is called by xinetd i.s.o. listening on a TCP socket itself.
I already have implemented a stand-alone XML-RPC server using SimpleXMLRPCServer, but I now want something similar, that is started via xinetd (i.e. reading/writing via stdin/stdout).
Any hints or code examples?
Thanks,
Isn't this just a standard daemon functionality?
So if you could wrap up your program in a daemon like fashion (e.g. http://homepage.hispeed.ch/py430/python/daemon.py) and then point the
xinetd configuration to the right script, it should just work?
Beware that I didn't try this myself yet ;-) though should do in the
near future so if you could give a head ups on your progress I would
appreciate it.
--
mph
On Sun, Apr 16, 2006 at 10:13:19PM +0200, Martin P. Hellwig wrote: Isn't this just a standard daemon functionality?
What is "a standard daemon"? :-)
So if you could wrap up your program in a daemon like fashion (e.g. http://homepage.hispeed.ch/py430/python/daemon.py) and then point the xinetd configuration to the right script, it should just work?
In fact, the standard use *is* a daemon (that is, accepting connections
on a certain port) and I want it to be *not* a daemon. For the daemon
method I use something similar to "daemonize", but now I want it to
*not* do the binds etc. to listen on a port.
The problem is that the server initialization *requires* a server
address (host, port pair), but I don't see how to tell it to use
the stdin socket (and I'm afraid this is not possible, but I'm not
sure).
--
-- Jos Vos <jo*@xos.nl>
-- X/OS Experts in Open Systems BV | Phone: +31 20 6938364
-- Amsterdam, The Netherlands | Fax: +31 20 6948204
Jos Vos wrote:
<cut> The problem is that the server initialization *requires* a server address (host, port pair), but I don't see how to tell it to use the stdin socket (and I'm afraid this is not possible, but I'm not sure).
If I understood it correctly you want the python server bind be
depending on whatever is configured in xinetd.conf and not be defined in
the your program itself?
I tested a bit around with my FreeBSD machine but indeed the OS
environment gives me nothing interesting back, leaving that option out
but I do can specify command line arguments so you could pick them up
with sys.argv.
I looked up how you can specify arguments in xinetd and according to
various resources I filtered out (gotta over these gnu type
documentation...) that you can use "server_args" in the per service
configuration to specify arguments.
Although not really elegant it is doable to do an on the fly port binding.
Now I just hope I understood your problem :-)
--
mph
Jos Vos <jo*@xos.nl> wrote: I'm trying to figure out how to implement a XML-RPC server that is called by xinetd i.s.o. listening on a TCP socket itself.
I already have implemented a stand-alone XML-RPC server using SimpleXMLRPCServer, but I now want something similar, that is started via xinetd (i.e. reading/writing via stdin/stdout).
Any hints or code examples?
UTSL ;-)
Look at /usr/lib/python2.4/SimpleXMLRPCServer.py (adjust as per your
distro) and in particular the definition of the CGIXMLRPCRequestHandler class.
That looks as thought it almost, or maybe completely, does what you
want, ie an XMLRPC subclass which reads from stdin and writes to
stdout.
--
Nick Craig-Wood <ni**@craig-wood.com> -- http://www.craig-wood.com/nick
On Mon, Apr 17, 2006 at 02:07:37AM +0200, Martin P. Hellwig wrote: If I understood it correctly you want the python server bind be depending on whatever is configured in xinetd.conf and not be defined in the your program itself?
I tested a bit around with my FreeBSD machine but indeed the OS environment gives me nothing interesting back, leaving that option out but I do can specify command line arguments so you could pick them up with sys.argv.
I looked up how you can specify arguments in xinetd and according to various resources I filtered out (gotta over these gnu type documentation...) that you can use "server_args" in the per service configuration to specify arguments.
Although not really elegant it is doable to do an on the fly port binding.
Now I just hope I understood your problem :-)
No, you didn't :-). I could add these options or even write an
xinetd-only program, that's all fine with me.
The problem is that I do not see how to let an SimpleXMLRPCServer
instance *not* bind to a port or what other class I can use to just
build a XML-RPC request handler reading/writing from stdin/stdout,
i.s.o. carrying all the server class stuff with it.
--
-- Jos Vos <jo*@xos.nl>
-- X/OS Experts in Open Systems BV | Phone: +31 20 6938364
-- Amsterdam, The Netherlands | Fax: +31 20 6948204
Jos Vos wrote: The problem is that I do not see how to let an SimpleXMLRPCServer instance *not* bind to a port or what other class I can use to just build a XML-RPC request handler reading/writing from stdin/stdout, i.s.o. carrying all the server class stuff with it.
I think that the problem here is that we are confusing transport with
request handling.
If you take a look at CGIXMLRPCRequestHandler
( http://docs.python.org/lib/node564.html), you will see an example of
how to write an XMLRPCRequestHandler without HTTP.
Cheers,
Brian
On Mon, Apr 17, 2006 at 12:10:15PM +0200, Brian Quinlan wrote: If you take a look at CGIXMLRPCRequestHandler (http://docs.python.org/lib/node564.html), you will see an example of how to write an XMLRPCRequestHandler without HTTP.
Thanks, this might work for me, will try it.
--
-- Jos Vos <jo*@xos.nl>
-- X/OS Experts in Open Systems BV | Phone: +31 20 6938364
-- Amsterdam, The Netherlands | Fax: +31 20 6948204
On Mon, Apr 17, 2006 at 03:30:04AM -0500, Nick Craig-Wood wrote: UTSL ;-)
Look at /usr/lib/python2.4/SimpleXMLRPCServer.py (adjust as per your distro) and in particular the definition of the CGIXMLRPCRequestHandler class.
I did this before posting my question, in fact, but I did not look
good enough maybe, as at first sight I thought tghe CGI... class
would be too CGI-specific (it looks for environment variables etc.
given by the HTTP server), but maybe it's good enough.
That looks as thought it almost, or maybe completely, does what you want, ie an XMLRPC subclass which reads from stdin and writes to stdout.
Will try...
--
-- Jos Vos <jo*@xos.nl>
-- X/OS Experts in Open Systems BV | Phone: +31 20 6938364
-- Amsterdam, The Netherlands | Fax: +31 20 6948204
Jos Vos wrote: On Mon, Apr 17, 2006 at 03:30:04AM -0500, Nick Craig-Wood wrote:
UTSL ;-)
Look at /usr/lib/python2.4/SimpleXMLRPCServer.py (adjust as per your distro) and in particular the definition of the CGIXMLRPCRequestHandler class.
I did this before posting my question, in fact, but I did not look good enough maybe, as at first sight I thought tghe CGI... class would be too CGI-specific (it looks for environment variables etc. given by the HTTP server), but maybe it's good enough.
I don't know exactly what your usage pattern is, but you might be able
to use SimpleXMLRPCDispatcher directly e.g. s = SimpleXMLRPCDispatcher() s.register_function(pow) s._marshaled_dispatch('<?xml version="1.0"...)
'<?xml version="1.0"...
Cheers,
Brian
Nick Craig-Wood wrote: Look at /usr/lib/python2.4/SimpleXMLRPCServer.py (adjust as per your distro) and in particular the definition of the CGIXMLRPCRequestHandler class.
That looks as thought it almost, or maybe completely, does what you want, ie an XMLRPC subclass which reads from stdin and writes to stdout.
except that if the OP's expecting the other end to use an ordinary XML-RPC
library, he needs to implement some minimal HTTP handling as well.
import sys
import mimetools, xmlrpclib
command = sys.stdin.readline()
# optional: check command syntax (POST url HTTP/1.X)
headers = mimetools.Message(sys.stdin)
# optional: check content-type etc
bytes = int(headers.get("content-length", 0))
# optional: check request size, etc
params, method = xmlrpclib.loads(sys.stdin.read(bytes))
# handle the method
result = ...
# marshaller expects a tuple
result = (result, )
response = xmlrpclib.dumps(result, methodresponse=1)
print "HTTP/1.0 200 OK"
print "Content-Type: text/xml"
print "Content-Length:", len(response)
print
print response
(based on code from http://effbot.org/zone/xmlrpc-cgi.htm )
</F>
On Mon, Apr 17, 2006 at 12:36:18PM +0200, Brian Quinlan wrote: I don't know exactly what your usage pattern is, but you might be able to use SimpleXMLRPCDispatcher directly e.g.
>>> s = SimpleXMLRPCDispatcher() >>> s.register_function(pow) >>> s._marshaled_dispatch('<?xml version="1.0"...)
'<?xml version="1.0"...
Will look at that too, but as I want to be able to use the same XML-RPC
client as I talk to with my SimpleXMLRPCServer (thus talking HTTP), I
think I need to CGI sugar.
Note that the main reason I'm looking to the "xinetd way" is that
I want to use proper SSL-based traffic and the SecureXMLRPCServer
flying around, using pyOpenSSL (or so), does not do a complete job
(because pyOpenSSL does not do a complete job IIRC) and needs to
be tweaked anyway, so I now hope to use stunnel.
--
-- Jos Vos <jo*@xos.nl>
-- X/OS Experts in Open Systems BV | Phone: +31 20 6938364
-- Amsterdam, The Netherlands | Fax: +31 20 6948204
On Mon, Apr 17, 2006 at 12:42:00PM +0200, Fredrik Lundh wrote: except that if the OP's expecting the other end to use an ordinary XML-RPC library, he needs to implement some minimal HTTP handling as well.
Which makes me wondering why the classes (this also applies to
BaseHTTPServer / BaseHTTPRequestHandler) ae designed the way they
are. The underlying stream medium (TCP sockets or plain file
streams like stdin/stdout) should not be integrated with the
protocol (HTTP) handling, IMHO...
--
-- Jos Vos <jo*@xos.nl>
-- X/OS Experts in Open Systems BV | Phone: +31 20 6938364
-- Amsterdam, The Netherlands | Fax: +31 20 6948204 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Phil Powell |
last post by:
// PROCESS XML CONTENT INTO DYNAMICALLY-NAMED ARRAYS
foreach (array('mime', 'state', 'country') as $val) {
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);...
|
by: Simon Strandgaard |
last post by:
I am trying to understand how to create a 'catalog.xml'
file for my docbook-xml documents. If I understand
correct a local catalog.xml file can both avoid hardcoding
in makefiles (portability),...
|
by: yzzzzz |
last post by:
Hi,
In which cases is the <?xml version="1.0" encoding="UTF-8"?> processing
instruction required at the beginning of an XML document, for the
document to be valid?
e.g. does it depend on the...
|
by: MarionEll |
last post by:
XML 2003 Exposition Draws Leading XML Vendors
Trade Show, Presentations Allow Companies to Showcase Cutting-edge Solutions
Alexandria, Va. - Dec. 1, 2003 - XML 2003, the world's largest XML...
|
by: Stylus Studio |
last post by:
World's Most Advanced XML Schema Editor Adds Support for IBM AlphaWorks
XML Schema Quality Checker to Improve XML Schema Style and Quality
BEDFORD, MA -- 09/13/2005 -- Stylus Studio...
|
by: Kurt Bauer |
last post by:
I have an ASP group calendar application which pulls calendar data from
Exchange via webdav into an XML string. I then loop the XML nodes to
populate a collection of appointments. Finally I use...
|
by: laks |
last post by:
Hi
I have the following xsl stmt.
<xsl:for-each select="JOB_POSTINGS/JOB_POSTING
\">
<xsl:sort select="JOB_TITLE" order="ascending"/>
This works fine when I use it.
But when using multiple...
|
by: jts2077 |
last post by:
I am trying to create a large nested XML object using E4X methods. The problem is the, the XML I am trying to create can only have xmlns set at the top 2 element levels. Such as:
<store
...
|
by: UncleRic |
last post by:
Environment: Mac OS X (10.4.10) on MacBook Pro
I'm a Perl Neophyte. I've downloaded the XML::Parser module and am attempting to install it in my working directory (referenced via PERL5LIB env):
...
|
by: Lie |
last post by:
Why this generates AttributeError, then not?
Python 2.5.2 (r252:60911, Apr 21 2008, 11:17:30)
on linux2
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
|
by: Johno34 |
last post by:
I have this click event on my form. It speaks to a Datasheet Subform
Private Sub Command260_Click()
Dim r As DAO.Recordset
Set r = Form_frmABCD.Form.RecordsetClone
r.MoveFirst
Do
If...
|
by: ezappsrUS |
last post by:
Hi,
I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
|
by: jack2019x |
last post by:
hello, Is there code or static lib for hook swapchain present?
I wanna hook dxgi swapchain present for dx11 and dx9.
| |