<P>Following is part of my test code. Please help me checking it. In my case, I need to use ip address to connect server directly.<BR>Thanks</P>
<P>//////////////////////////////////////////////////////////////////////<BR>// Server</P>
<P>int main(int argc, char** argv)<BR>{<BR>&nbsp; try {<BR>&nbsp;&nbsp; const char* options[][2] = { <BR>&nbsp;&nbsp;&nbsp; { "traceLevel", "40" },&nbsp;<BR>&nbsp;&nbsp;&nbsp; { "traceExceptions", "1" }, <BR>&nbsp;&nbsp;&nbsp; { "acceptBiDirectionalGIOP", "1" },<BR>&nbsp;&nbsp;&nbsp; { "serverTransportRule", "* unix,tcp,bidir" },&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp; { "endPoint", "giop:tcp::7788" },<BR>&nbsp;&nbsp;&nbsp; { 0, 0 } <BR>&nbsp;&nbsp; };&nbsp;&nbsp;</P>
<P>&nbsp;//&nbsp; Initialise the ORB.<BR>&nbsp;orb = CORBA::ORB_init(argc, argv,"omniORB4",options);</P>
<P>&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //CORBA::Object_var obj = orb-&gt;resolve_initial_references("RootPOA");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CORBA::Object_var obj = orb-&gt;resolve_initial_references("omniINSPOA"); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PortableServer::POA_var rootpoa = PortableServer::POA::_narrow(obj);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PortableServer::POAManager_var pman = rootpoa-&gt;the_POAManager();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pman-&gt;activate();</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Create a POA with the Bidirectional policy<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CORBA::PolicyList pl;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pl.length(1);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CORBA::Any a;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a &lt;&lt;= BiDirPolicy::BOTH;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pl[0] = orb-&gt;create_policy(BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE, a);</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PortableServer::POA_var poa = rootpoa-&gt;create_POA("bidir", pman, pl);</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; server_i* myserver = new server_i();<BR>&nbsp;&nbsp; PortableServer::ObjectId_var myserver_id = PortableServer::string_to_ObjectId("bidirService"); <BR>&nbsp;&nbsp; rootpoa-&gt;activate_object_with_id(myserver_id, myserver); </P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PortableServer::ObjectId_var oid = poa-&gt;activate_object(myserver);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; obj = myserver-&gt;_this();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myserver-&gt;_remove_ref();</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CORBA::String_var sior(orb-&gt;object_to_string(obj));<BR>&nbsp;&nbsp; cerr &lt;&lt;std::endl&lt;&lt; "id:'" &lt;&lt; (char*) sior &lt;&lt; "'" &lt;&lt; endl;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; orb-&gt;run();<BR>&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "bd_server: Returned from orb-&gt;run()." &lt;&lt; endl;<BR>&nbsp;&nbsp;&nbsp; orb-&gt;destroy();<BR>&nbsp; }<BR>&nbsp; catch(CORBA::SystemException&amp;) {<BR>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "Caught CORBA::SystemException." &lt;&lt; endl;<BR>&nbsp; }<BR>&nbsp; catch(CORBA::Exception&amp;) {<BR>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "Caught CORBA::Exception." &lt;&lt; endl;<BR>&nbsp; }<BR>&nbsp; catch(omniORB::fatalException&amp; fe) {<BR>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "Caught omniORB::fatalException:" &lt;&lt; endl;<BR>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "&nbsp; file: " &lt;&lt; fe.file() &lt;&lt; endl;<BR>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "&nbsp; line: " &lt;&lt; fe.line() &lt;&lt; endl;<BR>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "&nbsp; mesg: " &lt;&lt; fe.errmsg() &lt;&lt; endl;<BR>&nbsp; }<BR>&nbsp; catch(...) {<BR>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "Caught unknown exception." &lt;&lt; endl;<BR>&nbsp; }</P>
<P>&nbsp; return 0;<BR>}</P>
<P>&nbsp;</P>
<P><BR>//////////////////////////////////////////////////////////////////////<BR>//&nbsp; Client<BR>int main(int argc, char** argv)<BR>{<BR>&nbsp; try {</P>
<P>&nbsp;&nbsp; const char* options[][2] = { <BR>&nbsp;&nbsp;&nbsp; { "traceLevel", "40" },&nbsp;<BR>&nbsp;&nbsp;&nbsp; { "traceExceptions", "1" }, <BR>&nbsp;&nbsp;&nbsp; { "offerBiDirectionalGIOP", "1" },<BR>&nbsp;&nbsp;&nbsp; { "clientTransportRule", "* unix,tcp,bidir" },&nbsp;<BR>&nbsp;&nbsp;&nbsp; //{ "maxGIOPVerson", "1.2" },&nbsp;<BR>&nbsp;&nbsp;&nbsp; { 0, 0 } <BR>&nbsp;&nbsp; };&nbsp;&nbsp;</P>
<P>&nbsp;&nbsp; std::string srv_add;<BR>&nbsp;&nbsp; std::cerr &lt;&lt; "Input server IP:";<BR>&nbsp;&nbsp; std::getline(std::cin,srv_add);<BR>&nbsp;&nbsp; std::string obj_id("bidirService");</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Connect using ip address directly <BR>&nbsp;&nbsp; std::string srv_obj_id("corbaloc::");<BR>&nbsp;&nbsp; srv_obj_id.append(srv_add);<BR>&nbsp;&nbsp; srv_obj_id.append(":7788/");&nbsp; <BR>&nbsp;&nbsp; srv_obj_id.append(obj_id);&nbsp;<BR>&nbsp;&nbsp; std::cerr &lt;&lt; "Servant:" &lt;&lt; srv_obj_id &lt;&lt; std::endl ;<BR>&nbsp;&nbsp; //&nbsp; Initialise the ORB.<BR>&nbsp;&nbsp; CORBA::ORB_var orb = CORBA::ORB_init(argc, argv,"omniORB4",options);</P>
<P>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CORBA::Object_var obj;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Initialise the POA.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //obj = orb-&gt;resolve_initial_references("RootPOA");<BR>&nbsp;&nbsp; obj = orb-&gt;resolve_initial_references("omniINSPOA"); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PortableServer::POA_var rootpoa = PortableServer::POA::_narrow(obj);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PortableServer::POAManager_var pman = rootpoa-&gt;the_POAManager();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pman-&gt;activate();</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Create a POA with the Bidirectional policy<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CORBA::PolicyList pl;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pl.length(1);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CORBA::Any a;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a &lt;&lt;= BiDirPolicy::BOTH;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pl[0] = orb-&gt;create_policy(BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE, a);</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PortableServer::POA_var poa = rootpoa-&gt;create_POA("bidir", pman, pl);</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Get the reference the server.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; obj = orb-&gt;string_to_object(srv_obj_id.c_str());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //obj = orb-&gt;string_to_object(argv[1]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cb::Server_var server = cb::Server::_narrow(obj);</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Register a CallBack object in this process.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cb_i* mycallback = new cb_i();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PortableServer::ObjectId_var oid = poa-&gt;activate_object(mycallback);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cb::CallBack_var callback = mycallback-&gt;_this();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mycallback-&gt;_remove_ref();</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do_register(server, callback, 3,1000);</P>
<P>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; // Clean-up.&nbsp; This also destroys the call-back object.<BR>&nbsp;&nbsp;&nbsp; orb-&gt;destroy();<BR>&nbsp; }<BR>&nbsp; catch(CORBA::COMM_FAILURE&amp; ex) {<BR>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "Caught system exception COMM_FAILURE -- unable to contact the " &lt;&lt; "object." &lt;&lt; endl;<BR>&nbsp; }<BR>&nbsp; catch(CORBA::SystemException&amp;) {<BR>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "Caught a CORBA::SystemException." &lt;&lt; endl;<BR>&nbsp; }<BR>&nbsp; catch(CORBA::Exception&amp;) {<BR>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "Caught CORBA::Exception." &lt;&lt; endl;<BR>&nbsp; }<BR>&nbsp; catch(omniORB::fatalException&amp; fe) {<BR>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "Caught omniORB::fatalException:" &lt;&lt; endl;<BR>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "&nbsp; file: " &lt;&lt; fe.file() &lt;&lt; endl;<BR>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "&nbsp; line: " &lt;&lt; fe.line() &lt;&lt; endl;<BR>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "&nbsp; mesg: " &lt;&lt; fe.errmsg() &lt;&lt; endl;<BR>&nbsp; }<BR>&nbsp; catch(...) {<BR>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "Caught unknown exception." &lt;&lt; endl;<BR>&nbsp; }<BR>system("Pause");<BR>&nbsp; return 0;<BR>}</P>
<P><BR>----- Original Message -----<BR>From:David&nbsp;Bellette&nbsp;<DAVID@BELLETTE.NET><BR>To:<DEVMAIL@SINA.COM>,&nbsp;<OMNIORB-LIST@OMNIORB-SUPPORT.COM><BR>Subject:RE:&nbsp;[omniORB]&nbsp;Callback&nbsp;problem&nbsp;through&nbsp;NAT&nbsp;gateway&nbsp;with&nbsp;Omniorb<BR>Date:07-08-13 17:23:43<BR><BR>To&nbsp;get&nbsp;this&nbsp;scenario&nbsp;working&nbsp;you&nbsp;will&nbsp;need&nbsp;to&nbsp;use&nbsp;bi-direction&nbsp;GIOP.<BR>I've&nbsp;been&nbsp;using&nbsp;this&nbsp;for&nbsp;a&nbsp;few&nbsp;years&nbsp;now&nbsp;very&nbsp;successfully.<BR><BR>David<BR><BR><BR><BR>-----Original&nbsp;Message-----<BR>From:&nbsp;omniorb-list-bounces@omniorb-support.com<BR>[mailto:omniorb-list-bounces@omniorb-support.com]&nbsp;On&nbsp;Behalf&nbsp;Of&nbsp;devmail@sina.com<BR>Sent:&nbsp;Monday,&nbsp;13&nbsp;August&nbsp;2007&nbsp;7:11pm<BR>To:&nbsp;omniorb-list@omniorb-support.com<BR>Subject:&nbsp;[omniORB]&nbsp;Callback&nbsp;problem&nbsp;through&nbsp;NAT&nbsp;gateway&nbsp;with&nbsp;Omniorb<BR><BR>There&nbsp;is&nbsp;a&nbsp;client&nbsp;in&nbsp;private&nbsp;network&nbsp;and&nbsp;a&nbsp;server&nbsp;in&nbsp;public&nbsp;network.&nbsp;The&nbsp;private<BR>network&nbsp;use&nbsp;a&nbsp;NAT&nbsp;connected&nbsp;to&nbsp;the&nbsp;public&nbsp;network.<BR><BR>client(192.168.0.1)---------[192.168.0.2&nbsp;NAT&nbsp;200.1.1.2]----------server(200.1.1.<BR>1)<BR><BR>Referring&nbsp;to<BR><A href="http://www.omniorb-support.com/pipermail/omniorb-dev/2004-February/000138.html" target=_blank>http://www.omniorb-support.com/pipermail/omniorb-dev/2004-February/000138.html</A><BR>,&nbsp;a&nbsp;connection&nbsp;is&nbsp;setup.&nbsp;But&nbsp;callback&nbsp;is&nbsp;not&nbsp;successful.<BR><BR>In&nbsp;log&nbsp;messages,&nbsp;it&nbsp;is&nbsp;said&nbsp;that&nbsp;client&nbsp;send&nbsp;its&nbsp;address(192.168.0.1)&nbsp;in<BR>callback&nbsp;register&nbsp;messages&nbsp;to&nbsp;&nbsp;server&nbsp;and&nbsp;server&nbsp;use&nbsp;this&nbsp;address&nbsp;in&nbsp;callback.<BR>Cause&nbsp;client&nbsp;address&nbsp;is&nbsp;a&nbsp;private&nbsp;address&nbsp;and&nbsp;server&nbsp;can&nbsp;not&nbsp;resolve&nbsp;it,&nbsp;the<BR>callback&nbsp;failed.<BR><BR>How&nbsp;to&nbsp;make&nbsp;server&nbsp;to&nbsp;use&nbsp;gateway&nbsp;address(200.1.1.2)&nbsp;in&nbsp;callback?<BR><BR>Thanks&nbsp;a&nbsp;lot.<BR><BR><BR><BR></P><br />
<br />
-------------------------------------------------------------------<br />
MOTORAZR 系列颠覆之作,全新V8超大双屏手机( <a href=http://d1.sina.com.cn/sina/limeng3/mail_zhuiyu/2007/mail_zhuiyu_20070813.html target=_blank>http://d1.sina.com.cn/sina/limeng3/mail_zhuiyu/2007/mail_zhuiyu_20070813.html</a> )<br />
<br />
===================================================================<br />
注册新浪2G免费邮箱( <a href=http://mail.sina.com.cn/chooseMode.html target=_blank>http://mail.sina.com.cn/chooseMode.html</a> )