[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>&nbsp;</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&nbsp;starting the client&nbsp;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>&nbsp;</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
&lt;iostream.h&gt;<BR>#include "stdio.h"<BR>#include=20
"echo.hh"</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>static void=20
hello(DELFI3::Echo_ptr e) <BR>{<BR>&nbsp;CORBA::String_var src =3D =
(const char*)=20
"Hello!";<BR>&nbsp;CORBA::String_var dest =3D=20
e-&gt;echoString(src);</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>&nbsp;cerr &lt;&lt; =
"I said,=20
\"" &lt;&lt; (char*) src &lt;&lt; "\"." &lt;&lt; =
endl<BR>&nbsp;&nbsp;&lt;&lt;=20
"The Echo object replied, \"" &lt;&lt; (char*) dest &lt;&lt; "\"." =
&lt;&lt;=20
endl;<BR>}</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2>////////////////////////////////////////////////////////////////=
/////////////////////////////</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>int main(int argc, =
char**=20
argv)<BR>{<BR>&nbsp;char strobjid[1024];&nbsp;<BR>&nbsp;FILE*=20
oidfile=3Dfopen("oid.txt","r");<BR>&nbsp;fscanf(oidfile,"%s",strobjid);<B=
R>&nbsp;fclose(oidfile);</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>&nbsp;try=20
{<BR>&nbsp;&nbsp;CORBA::ORB_var orb =3D CORBA::ORB_init(argc, argv,=20
"omniORB3");</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT =
size=3D2>&nbsp;&nbsp;CORBA::Object_var=20
obj =3D =
orb-&gt;string_to_object(strobjid);<BR>&nbsp;&nbsp;DELFI3::Echo_var=20
echoref =3D DELFI3::Echo::_narrow(obj);<BR>&nbsp;&nbsp;if( =
CORBA::is_nil(echoref)=20
) {<BR>&nbsp;&nbsp;&nbsp;cerr &lt;&lt; "Can't narrow reference to type =
Echo (or=20
ot was nil)." &lt;&lt; endl;<BR>&nbsp;&nbsp;&nbsp;return=20
1;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;hello(echoref);<BR>&nbsp;&nbsp;hello(e=
choref);</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2>&nbsp;&nbsp;orb-&gt;destroy();<BR>&nbsp;}<BR>&nbsp;catch(CORBA::=
COMM_FAILURE&amp;=20
ex) {<BR>&nbsp;&nbsp;cerr &lt;&lt; "Caught system exception COMM_FAILURE =
--=20
unable to contact the " &lt;&lt; "object." &lt;&lt;=20
endl;<BR>&nbsp;}<BR>&nbsp;catch(CORBA::SystemException&amp;)=20
{<BR>&nbsp;&nbsp;cerr &lt;&lt; "Caught a CORBA::SystemException." =
&lt;&lt;=20
endl;<BR>&nbsp;}<BR>&nbsp;catch(CORBA::Exception&amp;) =
{<BR>&nbsp;&nbsp;cerr=20
&lt;&lt; "Caught CORBA::Exception." &lt;&lt;=20
endl;<BR>&nbsp;}<BR>&nbsp;catch(omniORB::fatalException&amp; fe)=20
{<BR>&nbsp;&nbsp;cerr &lt;&lt; "Caught omniORB::fatalException:" =
&lt;&lt;=20
endl;<BR>&nbsp;&nbsp;cerr &lt;&lt; "&nbsp; file: " &lt;&lt; fe.file() =
&lt;&lt;=20
endl;<BR>&nbsp;&nbsp;cerr &lt;&lt; "&nbsp; line: " &lt;&lt; fe.line() =
&lt;&lt;=20
endl;<BR>&nbsp;&nbsp;cerr &lt;&lt; "&nbsp; mesg: " &lt;&lt; fe.errmsg() =
&lt;&lt;=20
endl;<BR>&nbsp;}<BR>&nbsp;catch(...) {<BR>&nbsp;&nbsp;cerr &lt;&lt; =
"Caught=20
unknown exception." &lt;&lt; endl;<BR>&nbsp;}<BR>&nbsp;return=20
0;<BR>}<BR>//////////////////////////////////////////////////////////////=
/////////////////////////////////////////////////////////////////////////=
///////////////////////</FONT></SPAN></DIV>
<DIV><SPAN class=3D440374016-06032002><FONT =
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT =
size=3D2></FONT></SPAN>&nbsp;</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
&lt;iostream.h&gt;<BR>#include "echo.hh"</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>class Echo_i : =
public=20
POA_DELFI3::Echo,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public=20
PortableServer::RefCountServantBase<BR>{<BR>public:<BR>&nbsp;inline =
Echo_i()=20
{}<BR>&nbsp;virtual ~Echo_i() {}<BR>&nbsp;virtual char* echoString(const =
char*=20
mesg);<BR>};</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</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>&nbsp;return CORBA::string_dup(mesg);<BR>}</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2>////////////////////////////////////////////////////////////////=
//////////////////////<BR>int=20
main(int argc, char** argv)<BR>{<BR>&nbsp;FILE* =
oidfile;</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>&nbsp;oidfile =3D=20
fopen("oid.txt","w");</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>&nbsp;try=20
{<BR>&nbsp;&nbsp;CORBA::ORB_var orb =3D CORBA::ORB_init(argc,argv,=20
"omniORB3");<BR>&nbsp;&nbsp;CORBA::Object_var obj =3D=20
orb-&gt;resolve_initial_references("RootPOA");<BR>&nbsp;&nbsp;PortableSer=
ver::POA_var=20
poa =3D PortableServer::POA::_narrow(obj);</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>&nbsp;&nbsp;Echo_i* =
myecho =3D=20
new Echo_i();</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2>&nbsp;&nbsp;PortableServer::ObjectId_var myechoid =3D=20
poa-&gt;activate_object(myecho);</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>&nbsp;&nbsp;obj =3D =

myecho-&gt;_this();<BR>&nbsp;&nbsp;CORBA::String_var=20
sior(orb-&gt;object_to_string(obj));</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT size=3D2>&nbsp;&nbsp;cerr =
&lt;&lt; "'"=20
&lt;&lt; (char*)sior &lt;&lt; "'" &lt;&lt;=20
endl;<BR>&nbsp;&nbsp;fprintf(oidfile,"%s",(char*)sior);<BR>&nbsp;&nbsp;fc=
lose(oidfile);</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2>&nbsp;&nbsp;myecho-&gt;_remove_ref();</FONT></SPAN></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2>&nbsp;&nbsp;PortableServer::POAManager_var pman =3D=20
poa-&gt;the_POAManager();<BR>&nbsp;&nbsp;pman-&gt;activate();</FONT></SPA=
N></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2>&nbsp;&nbsp;orb-&gt;run();<BR>&nbsp;&nbsp;orb-&gt;destroy();</FO=
NT></SPAN></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002><FONT=20
size=3D2>&nbsp;}<BR>&nbsp;catch(CORBA::SystemException&amp;) =
{<BR>&nbsp;&nbsp;cerr=20
&lt;&lt; "Caught CORBA::SystemException." &lt;&lt;=20
endl;<BR>&nbsp;}<BR>&nbsp;catch(CORBA::Exception&amp;) =
{<BR>&nbsp;&nbsp;cerr=20
&lt;&lt; "Caught CORBA::Exception." &lt;&lt;=20
endl;<BR>&nbsp;}<BR>&nbsp;catch(omniORB::fatalException&amp; fe)=20
{<BR>&nbsp;&nbsp;cerr &lt;&lt; "Caught omniORB::fatalException:" =
&lt;&lt;=20
endl;<BR>&nbsp;&nbsp;cerr &lt;&lt; " file: " &lt;&lt; fe.file() &lt;&lt; =

endl;<BR>&nbsp;&nbsp;cerr &lt;&lt; " line: " &lt;&lt; fe.line() &lt;&lt; =

endl;<BR>&nbsp;&nbsp;cerr &lt;&lt; " mesg: " &lt;&lt; fe.errmsg() =
&lt;&lt;=20
endl;<BR>&nbsp;}<BR>&nbsp;catch(...) {<BR>&nbsp;&nbsp;cerr &lt;&lt; =
"Caught=20
unknown exception." &lt;&lt; endl;<BR>&nbsp;}<BR>&nbsp;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>&nbsp;</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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; interface Echo =

{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
string echoString(in string =
mesg);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=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>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002>Can anybody help?</SPAN></DIV>
<DIV><SPAN class=3D440374016-06032002></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002>Thanks</SPAN></DIV>
<DIV><SPAN class=3D440374016-06032002></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D440374016-06032002>Frank Reinartz</SPAN></DIV>
<DIV><SPAN=20
class=3D440374016-06032002></SPAN>&nbsp;</DIV></FONT></SPAN></DIV></BODY>=
</HTML>

------=_NextPart_000_0019_01C1C539.12868CA0--