[omniORB] Multiple servers pinning the same port?

Peter-Rene Steiner peter-rene.steiner@bruker.de
Thu, 19 Jul 2001 13:04:09 +0200


Hi Bruce,

AFAIK there is no option to choose omniORB3's behavior on using
a port that is already occupied. When specifying a port (e.g. with
-ORBpoa_iiop_port) omniORB simply 'uses' that port.

Below you will find the relevant code from 
omni303\src\lib\omniORB2\orbcore\tcpSocketMTfactory.cc, line 611ff. .

I have changed line 612 to 'int valtrue = 0' so SO_REUSEADDR is set to false and bind()
returns an error (resulting in the common CORBA exception). This seems to work perfectly 
for me. If you want to implement a loop finding a free port within a pre-defined range
you can contact me for necessary (but small) source modifications.

Please note that the operating system may not free a TCP/IP port for a specified time
after it has been used by an application: A quick stop-and-restart on the same port 
may fail for this reason. See earlier postings in the omniorb-list.

(BTW, AT&T people: great work, and omniORB4 seems to become even better!)

Best regards,
Peter-Rene

-------------------------------------

  if (e->port()) {
    int valtrue = 1;
    if (setsockopt(pd_rendezvous,SOL_SOCKET,
     SO_REUSEADDR,(char*)&valtrue,sizeof(int)) == RC_SOCKET_ERROR)
      {
 CLOSESOCKET(pd_rendezvous);
#     ifndef __WIN32__
 OMNIORB_THROW_CONNECTION_BROKEN(errno,CORBA::COMPLETED_NO);
#     else
 OMNIORB_THROW_CONNECTION_BROKEN(::WSAGetLastError(),
     CORBA::COMPLETED_NO);
#     endif
      }
  }

  if (bind(pd_rendezvous,(struct sockaddr *)&myaddr,
    sizeof(struct sockaddr_in)) == RC_SOCKET_ERROR) 
  {
    CLOSESOCKET(pd_rendezvous);
# ifndef __WIN32__
    OMNIORB_THROW_CONNECTION_BROKEN(errno,CORBA::COMPLETED_NO);
# else
    OMNIORB_THROW_CONNECTION_BROKEN(::WSAGetLastError(),CORBA::COMPLETED_NO);
# endif

----- Original Message ----- 
From: Bruce Fountain <B_Fountain@motherwell.com.au>
To: <omniorb-list@uk.research.att.com>
Sent: Wednesday, July 18, 2001 4:19 AM
Subject: [omniORB] Multiple servers pinning the same port?


> Hi guys,
> 
> I have noticed that omniORB seems quite happy to
> seize control of a port that is already being used
> by another server. For instance, you can run two
> naming services on the same port. INS-addressed
> requests seem to go to the first server. If the
> first server is terminated the second server takes
> over handling of requests.
> 
> I know ORBacus will throw an exception on ORB_init()
> if there is contention for a port, which I found
> very useful. Is there some way of checking for this
> condition with omni?
> 
> Bruce Fountain
> Mi Consulting Group (Australia) Pty Ltd
> Direct Line:  +61 (0)8 9368 8607
> Switchboard:  +61 (0)8 9368 8600
> Facsimile:    +61 (0)8 9368 8699
> E-mail: b_fountain@motherwell.com.au
>