[omniORB] Date: Wed, 6 Mar 2002 18:02:24 +0100
Frank Reinartz
ref@ivv-aachen.de
Wed, 06 Mar 2002 17:02:25 +0000
This is a multi-part message in MIME format.
------=_NextPart_000_0019_01C1C539.12868CA0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Hello!
I have a problem calling a method of a corba interface for several times. I
took example 2 (eg2_ctl.cc) and compiled it with MS Visual C++ 6.0 using
OmniOrb 3.0.4. In the client I dubbled the line hello(echoref); . It works
properly on Win98 and Win NT systems , but on W2K (Pro) it doesn't work.
After first start of the client the server prints a tcpSocketMT Exception.
When I repeate starting the client for several times the server doesn't
answer anymore und blocks the client after the third execution.
My code:
////////////////////////////////////////////////////////// Client
//////////////////////////////////////////////////////////////////////
#include <iostream.h>
#include "stdio.h"
#include "echo.hh"
static void hello(DELFI3::Echo_ptr e)
{
CORBA::String_var src = (const char*) "Hello!";
CORBA::String_var dest = e->echoString(src);
cerr << "I said, \"" << (char*) src << "\"." << endl
<< "The Echo object replied, \"" << (char*) dest << "\"." << endl;
}
////////////////////////////////////////////////////////////////////////////
/////////////////
int main(int argc, char** argv)
{
char strobjid[1024];
FILE* oidfile=fopen("oid.txt","r");
fscanf(oidfile,"%s",strobjid);
fclose(oidfile);
try {
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3");
CORBA::Object_var obj = orb->string_to_object(strobjid);
DELFI3::Echo_var echoref = DELFI3::Echo::_narrow(obj);
if( CORBA::is_nil(echoref) ) {
cerr << "Can't narrow reference to type Echo (or ot was nil)." << endl;
return 1;
}
hello(echoref);
hello(echoref);
orb->destroy();
}
catch(CORBA::COMM_FAILURE& ex) {
cerr << "Caught system exception COMM_FAILURE -- unable to contact the "
<< "object." << endl;
}
catch(CORBA::SystemException&) {
cerr << "Caught a CORBA::SystemException." << endl;
}
catch(CORBA::Exception&) {
cerr << "Caught CORBA::Exception." << endl;
}
catch(omniORB::fatalException& fe) {
cerr << "Caught omniORB::fatalException:" << endl;
cerr << " file: " << fe.file() << endl;
cerr << " line: " << fe.line() << endl;
cerr << " mesg: " << fe.errmsg() << endl;
}
catch(...) {
cerr << "Caught unknown exception." << endl;
}
return 0;
}
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
//////
/////////////////////////////////////////////////////////////// Server
////////////////////////////////////////////////////////////////////////////
///////
#include "stdio.h"
#include <iostream.h>
#include "echo.hh"
class Echo_i : public POA_DELFI3::Echo,
public PortableServer::RefCountServantBase
{
public:
inline Echo_i() {}
virtual ~Echo_i() {}
virtual char* echoString(const char* mesg);
};
char* Echo_i::echoString(const char* mesg)
{
return CORBA::string_dup(mesg);
}
////////////////////////////////////////////////////////////////////////////
//////////
int main(int argc, char** argv)
{
FILE* oidfile;
oidfile = fopen("oid.txt","w");
try {
CORBA::ORB_var orb = CORBA::ORB_init(argc,argv, "omniORB3");
CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
Echo_i* myecho = new Echo_i();
PortableServer::ObjectId_var myechoid = poa->activate_object(myecho);
obj = myecho->_this();
CORBA::String_var sior(orb->object_to_string(obj));
cerr << "'" << (char*)sior << "'" << endl;
fprintf(oidfile,"%s",(char*)sior);
fclose(oidfile);
myecho->_remove_ref();
PortableServer::POAManager_var pman = poa->the_POAManager();
pman->activate();
orb->run();
orb->destroy();
}
catch(CORBA::SystemException&) {
cerr << "Caught CORBA::SystemException." << endl;
}
catch(CORBA::Exception&) {
cerr << "Caught CORBA::Exception." << endl;
}
catch(omniORB::fatalException& fe) {
cerr << "Caught omniORB::fatalException:" << endl;
cerr << " file: " << fe.file() << endl;
cerr << " line: " << fe.line() << endl;
cerr << " mesg: " << fe.errmsg() << endl;
}
catch(...) {
cerr << "Caught unknown exception." << endl;
}
return 0;
}
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
//////
//////////////////////////////////////////////////// IDL
////////////////////////////////////////////////////////////////////////////
///////////////////////
module DELFI3
{
interface Echo {
string echoString(in string mesg);
};
};
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
//////
Can anybody help?
Thanks
Frank Reinartz
------=_NextPart_000_0019_01C1C539.12868CA0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2712.300" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D440374016-06032002><FONT =
size=3D2>Hello!</FONT></SPAN></DIV>
<DIV><SPAN class=3D440374016-06032002><FONT =
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>I have a problem =
calling a=20
method of a corba interface for several times. I took example 2 =
(eg2_ctl.cc) and=20
compiled it with MS Visual C++ 6.0 using OmniOrb 3.0.4. In the client I =
dubbled=20
the line </FONT></SPAN><SPAN class=3D440374016-06032002><FONT=20
size=3D2>hello(echoref); . It works properly on Win98 and Win NT systems =
, but on=20
W2K (Pro) it doesn't work. After first start of the client the server =
prints a=20
tcpSocketMT Exception. When I repeate starting the client for =
several=20
times the server doesn't answer anymore und blocks the client after the =
third=20
execution.</FONT></SPAN></DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>My =
code:</FONT></SPAN></DIV>
<DIV><SPAN class=3D440374016-06032002><FONT =
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2>////////////////////////////////////////////////////////// =
Client=20
//////////////////////////////////////////////////////////////////////</F=
ONT></SPAN></DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>#include=20
<iostream.h><BR>#include "stdio.h"<BR>#include=20
"echo.hh"</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>static void=20
hello(DELFI3::Echo_ptr e) <BR>{<BR> CORBA::String_var src =3D =
(const char*)=20
"Hello!";<BR> CORBA::String_var dest =3D=20
e->echoString(src);</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2> cerr << =
"I said,=20
\"" << (char*) src << "\"." << =
endl<BR> <<=20
"The Echo object replied, \"" << (char*) dest << "\"." =
<<=20
endl;<BR>}</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2>////////////////////////////////////////////////////////////////=
/////////////////////////////</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>int main(int argc, =
char**=20
argv)<BR>{<BR> char strobjid[1024]; <BR> FILE*=20
oidfile=3Dfopen("oid.txt","r");<BR> fscanf(oidfile,"%s",strobjid);<B=
R> fclose(oidfile);</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2> try=20
{<BR> CORBA::ORB_var orb =3D CORBA::ORB_init(argc, argv,=20
"omniORB3");</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT =
size=3D2> CORBA::Object_var=20
obj =3D =
orb->string_to_object(strobjid);<BR> DELFI3::Echo_var=20
echoref =3D DELFI3::Echo::_narrow(obj);<BR> if( =
CORBA::is_nil(echoref)=20
) {<BR> cerr << "Can't narrow reference to type =
Echo (or=20
ot was nil)." << endl;<BR> return=20
1;<BR> }<BR> hello(echoref);<BR> hello(e=
choref);</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2> orb->destroy();<BR> }<BR> catch(CORBA::=
COMM_FAILURE&=20
ex) {<BR> cerr << "Caught system exception COMM_FAILURE =
--=20
unable to contact the " << "object." <<=20
endl;<BR> }<BR> catch(CORBA::SystemException&)=20
{<BR> cerr << "Caught a CORBA::SystemException." =
<<=20
endl;<BR> }<BR> catch(CORBA::Exception&) =
{<BR> cerr=20
<< "Caught CORBA::Exception." <<=20
endl;<BR> }<BR> catch(omniORB::fatalException& fe)=20
{<BR> cerr << "Caught omniORB::fatalException:" =
<<=20
endl;<BR> cerr << " file: " << fe.file() =
<<=20
endl;<BR> cerr << " line: " << fe.line() =
<<=20
endl;<BR> cerr << " mesg: " << fe.errmsg() =
<<=20
endl;<BR> }<BR> catch(...) {<BR> cerr << =
"Caught=20
unknown exception." << endl;<BR> }<BR> return=20
0;<BR>}<BR>//////////////////////////////////////////////////////////////=
/////////////////////////////////////////////////////////////////////////=
///////////////////////</FONT></SPAN></DIV>
<DIV><SPAN class=3D440374016-06032002><FONT =
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT =
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2>/////////////////////////////////////////////////////////////// =
Server=20
/////////////////////////////////////////////////////////////////////////=
//////////</FONT></SPAN></DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>#include =
"stdio.h"<BR>#include=20
<iostream.h><BR>#include "echo.hh"</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>class Echo_i : =
public=20
POA_DELFI3::Echo,<BR> public=20
PortableServer::RefCountServantBase<BR>{<BR>public:<BR> inline =
Echo_i()=20
{}<BR> virtual ~Echo_i() {}<BR> virtual char* echoString(const =
char*=20
mesg);<BR>};</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>char* =
Echo_i::echoString(const=20
char* mesg)<BR>{<BR></FONT></SPAN><SPAN class=3D440374016-06032002><FONT =
size=3D2> return CORBA::string_dup(mesg);<BR>}</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2>////////////////////////////////////////////////////////////////=
//////////////////////<BR>int=20
main(int argc, char** argv)<BR>{<BR> FILE* =
oidfile;</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2> oidfile =3D=20
fopen("oid.txt","w");</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2> try=20
{<BR> CORBA::ORB_var orb =3D CORBA::ORB_init(argc,argv,=20
"omniORB3");<BR> CORBA::Object_var obj =3D=20
orb->resolve_initial_references("RootPOA");<BR> PortableSer=
ver::POA_var=20
poa =3D PortableServer::POA::_narrow(obj);</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2> Echo_i* =
myecho =3D=20
new Echo_i();</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2> PortableServer::ObjectId_var myechoid =3D=20
poa->activate_object(myecho);</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2> obj =3D =
myecho->_this();<BR> CORBA::String_var=20
sior(orb->object_to_string(obj));</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2> cerr =
<< "'"=20
<< (char*)sior << "'" <<=20
endl;<BR> fprintf(oidfile,"%s",(char*)sior);<BR> fc=
lose(oidfile);</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2> myecho->_remove_ref();</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2> PortableServer::POAManager_var pman =3D=20
poa->the_POAManager();<BR> pman->activate();</FONT></SPA=
N></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2> orb->run();<BR> orb->destroy();</FO=
NT></SPAN></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2> }<BR> catch(CORBA::SystemException&) =
{<BR> cerr=20
<< "Caught CORBA::SystemException." <<=20
endl;<BR> }<BR> catch(CORBA::Exception&) =
{<BR> cerr=20
<< "Caught CORBA::Exception." <<=20
endl;<BR> }<BR> catch(omniORB::fatalException& fe)=20
{<BR> cerr << "Caught omniORB::fatalException:" =
<<=20
endl;<BR> cerr << " file: " << fe.file() << =
endl;<BR> cerr << " line: " << fe.line() << =
endl;<BR> cerr << " mesg: " << fe.errmsg() =
<<=20
endl;<BR> }<BR> catch(...) {<BR> cerr << =
"Caught=20
unknown exception." << endl;<BR> }<BR> return=20
0;<BR>}</FONT></SPAN></DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2>////////////////////////////////////////////////////////////////=
/////////////////////////////////////////////////////////////////////////=
/////////////////////</FONT></SPAN></DIV>
<DIV><SPAN class=3D440374016-06032002><FONT =
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2>//////////////////////////////////////////////////// IDL=20
/////////////////////////////////////////////////////////////////////////=
//////////////////////////</FONT></SPAN></DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>module=20
DELFI3<BR>{<BR> interface Echo =
{<BR> &n=
bsp; =20
string echoString(in string =
mesg);<BR> =20
};<BR>};</FONT></SPAN></DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2>////////////////////////////////////////////////////////////////=
/////////////////////////////////////////////////////////////////////////=
/////////////////////</FONT></SPAN></DIV>
<DIV><SPAN class=3D440374016-06032002></SPAN> </DIV>
<DIV><SPAN class=3D440374016-06032002>Can anybody help?</SPAN></DIV>
<DIV><SPAN class=3D440374016-06032002></SPAN> </DIV>
<DIV><SPAN class=3D440374016-06032002></SPAN> </DIV>
<DIV><SPAN class=3D440374016-06032002>Thanks</SPAN></DIV>
<DIV><SPAN class=3D440374016-06032002></SPAN> </DIV>
<DIV><SPAN class=3D440374016-06032002>Frank Reinartz</SPAN></DIV>
<DIV><SPAN=20
class=3D440374016-06032002></SPAN> </DIV></FONT></SPAN></DIV></BODY>=
</HTML>
------=_NextPart_000_0019_01C1C539.12868CA0--