Привет всем У меня есть вопрос, связанный с Pyro4 и Java. Мой вопрос в том, как я могу отправить информацию между сервером RMI в Java и клиентами RMI в Python ?. Это мой код, у меня нет никаких ошибок, но я ничего не могу отправить.Pyro4 connect with java
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
прокси = Pyro4.core.Proxy ("PYRONAME: PhDJara/127,0 .1.1 ")
print (" 5 * 11 =% d "% proxy.multiply (5,11)) print (" 'x' * 10 =% s "% proxy.multiply ('x', 10))
Благодарим за помощь.
jarain78
В начале класса Java есть что-то отсутствует. Я не вижу смысла в поле 'thIsAddress'. Серверы RMI не должны знать свой собственный IP-адрес. – EJP