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