The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Java and Python IPC..

I (we) are currently migrating a server application from Python to Java.  To speed us up, I'm thinking of spinning the current Python server to just provide services to the Java server using some form of IPC.

The 2 servers will always be on the same machine.  I could either roll my own protocol, use SOAP (which seems simple) or use REST, which is simple like SOAP, but does require a little more programmer work.

Any opinions?  Am I missing an RPC/IPC technology here that might even be better?

Using JNI to create a bridge between the 2 is feasable, but having process separation is appealing.

Thanks.
Ace Nimrod Send private email
Thursday, October 04, 2007
 
 
Use XMLRPC.  Much simpler than SOAP, and well supported in both Python (in the standard library) and Java (by the Apache XMLRPC library).
Richie Hindle Send private email
Thursday, October 04, 2007
 
 
If the python server can run under Jython then you can use java RMI to communicate. Note that I wouldn't recommend this as a long term communications architecture but as a short term shim it would work..
Matt. Send private email
Thursday, October 04, 2007
 
 
I will look at XMLRPC.

Portions run under Jython, but some parts don't - custom C exensions and what not that are destined to be rewritten/redesigned in Java at some point.
Ace Nimrod Send private email
Thursday, October 04, 2007
 
 
Check out ICE (google for internet communication engine)...
Might be worth a try.
Fritz Send private email
Thursday, October 04, 2007
 
 
I'd recommend XML-RPC as well. Don't use SOAP -- it is *not* simple, especially if you're using different toolkits on the client & server.
Been burned by SOAP
Thursday, October 04, 2007
 
 
Python has a function called 'eval', and a function called 'repr'. If you can send an arbitrary string over a socket (or any other pipe), you can do pretty nasty things. I don't know how you would do it in Java / Jython, but here are two python scripts that can speak to each other. I'm not sure if the use of 'eval' in this context would create a vulnerability though, that would take some research.

(adapted from the Python documentation, socket example, note that 'eat_spam' is only defined in the the 'sever' script):

# Script 1: server program
def eat_spam(eggs):
    return "It's just a flesh wound"

import socket

HOST = 'localhost'             
PORT = 50007
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr
while 1:
    data = conn.recv(1024)
    if not data: break
    response=eval(data)
    response_str=repr(response)
    conn.send(response_str)

conn.close()

# Script 2: client program
import socket

HOST = 'localhost'   
PORT = 50007           
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
args=(3,4)
function_name='eat_spam'

s.send('%s(%s)'%(function_name,repr(args)))
data = s.recv(1024)
data=eval(data)
s.close()
print 'Received', repr(data)
PeterR Send private email
Saturday, October 06, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz