嗨,我有关于Pyro4和Java的所有问题。我的问题是如何在Java中的RMI服务器和Python中的客户端RMI之间发送信息?这是我的代码,我没有任何错误,但我不能发送任何东西。
Java代码:
implements ReceiveMessageInterface
{
int thisPort;
String thisAddress;
Registry registry; // rmi registry for lookup the remote objects.
// This method is called from the remote client by the RMI.
// This is the implementation of the �gReceiveMessageInterface�h.
public void receiveMessage(String x) throws RemoteException
{
System.out.println(x);
}
public RmiServer() throws RemoteException
{
try{
// get the address of this host.
thisAddress= (InetAddress.getLocalHost()).toString();
}
catch(Exception e){
throw new RemoteException("can't get inet address.");
}
thisPort=3232; // this port(registry�fs port)
System.out.println("this address="+thisAddress+",port="+thisPort);
try{
// create the registry and bind the name and object.
registry = LocateRegistry.createRegistry( thisPort );
registry.rebind("rmiServer", this);
}
catch(RemoteException e){
throw e;
}
}
static public void main(String args[])
{
try{
RmiServer s=new RmiServer();
}
catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
}这是我用Python编写的代码:
导入Pyro4 proxy=Pyro4.core.Proxy("PYRONAME:PhDJara/127.0.1.1") 打印(“5*11=%d”% proxy.multiply(5,11))打印(“x‘*10=%s”% proxy.multiply('x',10))
谢谢你的帮助。
jarain78
发布于 2015-02-14 17:56:14
是什么使你认为你应该能够把这两者联系起来?Pyro4在概念上与Java相似,但它们是完全不同的两种协议。你不能直接连接它们。
如果您想使用Pyro编写Python客户机并与服务器对话,则该服务器必须是Pyro服务器。在Java中创建Java的唯一方法是使用Jython + Pyro。
https://stackoverflow.com/questions/28488697
复制相似问题