Hi all,

I am working on Socket communication between XPCOM component and a Server Socket.

After establishing the connection between client (XPCOM Component) and Server (server socket), the server tries to pass a message to the client ("You are connected").

The client receives messages sent by server in a thread.

While trying to print the retrieved message, i got the message string with some extra characters added to it.

The characters looks something like  this "You are ConnectedòÂ>ñx/LºÃ- "

How to get rid of this extra characters?

The Component code is attached with this.

Please help me in this regard.

Thanks in advance
S.Srinivasa Raghavan


--
WhoAmI S.Srinivasa Raghavan
AdventNet Development Center
11, Sarathy Nagar,
Vijaya Nagar, Velacherry,

Chennai - 600 042.
Ph : 22431115 , 22431215 Extn : 5417


"Our greatest glory was not in never falling, but in rising when we  fell"- Vince Lombardi


NS_IMPL_ISUPPORTS3_CI(nsSimpleImpl, nsISimple , nsIRunnable)

nsSimpleImpl::nsSimpleImpl()
{
  NS_INIT_ISUPPORTS();

        OpenSocket(); 
  /* member initializers and constructor code */
}

nsSimpleImpl::~nsSimpleImpl()
{
  /* destructor code */
}

/* void openSocket (); */
NS_IMETHODIMP nsSimpleImpl::OpenSocket()
{
        nsresult rv; 
        cli.create();
        cli.connect("127.0.0.1",6001);
        nsCOMPtr<nsIThread> thread;
        rv = NS_NewThread(getter_AddRefs(thread),this,0);       
        if(NS_SUCCEEDED(rv))
        {
                string message =" client connected to server";
                cli.send(message);
        }

    return NS_OK;
}


NS_IMETHODIMP nsSimpleImpl::Run()
{
        PRBool continueService = true;

        char* message;  
        
        
        nsString ns;
        
        while(continueService)
        {
                cli.recieve(&message);
                
                cout<<message;

        }                               
        return NS_OK;
}

Reply via email to