LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Problem with CORBA (impl language Java) (https://www.linuxquestions.org/questions/programming-9/problem-with-corba-impl-language-java-486263/)

vivekr 09-23-2006 10:47 AM

Problem with CORBA (impl language Java)
 
Code:

import Chat.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POA;
import java.util.*;

public class ChatClientImpl extends ChatClientPOA
{
  static Vector clients=new Vector();
  public void send(String message)
  {
           
  }

  public static Binding[] listBindings(NamingContextExt nc,int max)
            throws org.omg.CORBA.UserException
  {
          Binding[]  basicList;
          BindingIterator bIter;
       
          org.omg.CORBA.Object obj;         
       
          BindingListHolder basicList_out=new BindingListHolder();
          BindingIteratorHolder bIter_out= new BindingIteratorHolder();
          nc.list(max,basicList_out,bIter_out);
          basicList = basicList_out.value;
          bIter = bIter_out.value;
       
          int  max_remaining = max - basicList.length;
          boolean moreBindings = (bIter!=null);
       
          if (moreBindings) {
              while (moreBindings && (max_remaining > 0) ) {
                Binding[] tmpList;
                Binding[] oldList;
                BindingListHolder tmpList_out=new BindingListHolder();
                moreBindings = bIter.next_n(max,tmpList_out);
                tmpList = tmpList_out.value;
                //Append 'tmpList' to 'basicList'
                oldList = basicList;
                basicList = new Binding[oldList.length+tmpList.length];
                for (int i=0; i < oldList.length; i++) {
                  basicList[i] = oldList[i];
                }
                for (int i=0; i < tmpList.length; i++) {
                  basicList[i+oldList.length] = tmpList[i];
                }
                // Re-calculate 'max_remaining'
                max_remaining = max - basicList.length;
            }
            bIter.destroy();
        }
        return basicList;
  }
 
  public void receive(String message)
  {
                  System.out.println(message);
  }
 
  public static void main(String args[])
  {
          try
          {         
                  ORB orb=ORB.init(args,null);
                  POA poa=POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
                  poa.the_POAManager().activate();
                  ChatClientImpl client=new ChatClientImpl();
                  // client.setORB(orb);
            org.omg.CORBA.Object ref=poa.servant_to_reference(client);
                ChatClient clientRef=ChatClientHelper.narrow(ref);
                org.omg.CORBA.Object objRef=orb.resolve_initial_references("NameService");
                NamingContextExt context=NamingContextExtHelper.narrow(objRef);
                java.io.DataInputStream in=new java.io.DataInputStream(System.in);
                String name=in.readLine();
                clients.add(name);
                NameComponent path[]=context.to_name(name);
                System.out.println("client binded..");
                context.rebind(path, clientRef);
                String msg=in.readLine();               
                Binding[] bindings=ChatClientImpl.listBindings(context,20);
                for(int i=0;i<bindings.length;i++)
                {                                                 
                /*        String name2=(String) e.nextElement();
                          System.out.println("Sent to "+name2);*/
                        ChatClient chat= ChatClientHelper.narrow(context.resolve(bindings[i].binding_name));
                        chat.receive("Hai");
                }
                orb.run();       
                orb.shutdown(true);
          }
          catch(Exception e)
          {
                  e.printStackTrace();
          }
  }
}

I am in the preliminary stages of creating a chat application. Here to begin with application runs perfectly.. But after resloving other clients. It goes wild
Code:

@client1:
I:\Vivek\CORBA\ChatProj>java ChatClientImpl
sanjay
client binded..
hai
Hai
Sep 23, 2006 9:08:25 PM com.sun.corba.se.impl.transport.SocketOrChannelConnectio
nImpl <init>
WARNING: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR
_TEXT; hostname: 192.168.1.69; port: 2588"
.....


@client2:
I:\Vivek\CORBA\ChatProj>java ChatClientImpl
vivek
client binded..
Hai
hello
Hai
Sep 23, 2006 9:08:34 PM com.sun.corba.se.impl.transport.SocketOrChannelConnectio
nImpl <init>
WARNING: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR
_TEXT; hostname: 192.168.1.69; port: 3210"
.....


Can anyone suggest me a good alternative to get rid of this behaviour.. Thanks in advance


All times are GMT -5. The time now is 10:40 PM.