CORBA :: Get the client ORB address and port with use of IIOP

与世无争的帅哥 提交于 2019-12-12 12:37:56

问题


I have application in CORBA using IIOP protocol, i am using the Java IDL component of the JDK 6 , another ORB implementation.

Implementation of both client and server in Java language.

Is there any way in the JDK ORB implementation to get the client ORB`s host and port from the server (ORB)code ?

Or

is there any way with use of IIOP protocol, get client the host and port ?

This is we are doing for identification of the client to track the who is requested


回答1:


I don't think there is any portable way to do this. Perhaps there is for your particular ORB, I don't know. Recall that CORBA tries very hard to hide the transport details from the application. The application may not even be using IIOP, and thus there would be no way to get TCP host and port information in any event.

You may want to consider adding additional identifier parameter(s) to your IDL so that the server can recognize clients. You may also consider making the clients call a "register" function on the server, and the server hands out an identifier that all clients must pass back to the server on subsequent calls.

This identifier can be as simple as a string or integer, or as complicated as some kind of security token that the server has to validate with a public key. It all depends on your application's requirements.




回答2:


It depends on the situation but sometimes you need to extract host/port from IOR for testing, logging, debugging purposes. IOR contains host and port, you only need to decode it from byte array that IOR represents. So just take CORBA specification and IorParser.java(massive dependencies) from GNU Classpath as example and do decoding yourself if you have time during weekend :)

If you do not have time as me, you can use command line utilities that are coming with ORBs:

  1. tao_catior in TAO/ACE ORB
  2. iordump in Orbix/Orbacus ORB's
  3. Parse IOR with web online tool http://www2.parc.com/istl/projects/ILU/parseIOR/
  4. Have not found possibility to use JDK CORBA to do the parsing. Although the code is definitely somewhere in internal sun packages.
  5. dior in Jacorb ORB. Or java jacorb.Orb.util.PrintIOR -i [IOR-string]

For me the answer #5 was good enough. I used Jacorb for my java based testing tool. But then again PrintIOR requires org.jacorb.orb.ORB to be instantiated by org.omg.CORBA.ORB.init(). So it can be tricky if you are forced to use JDK ORB in the same JVM.




回答3:


This is duplicated by Identify client in peer to peer filesharing using Java and Corba. And build socket socket between 2 Clients

There is a solution given based on JacORB.



来源:https://stackoverflow.com/questions/14479816/corba-get-the-client-orb-address-and-port-with-use-of-iiop

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!