CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Threaded View

  1. #1
    Join Date
    Aug 2004
    Location
    Pakistan
    Posts
    260

    passing string from RPC client to server

    Hi,

    I need to return the string data from the RPC function that i am calling. String will be very dynamic so i am interested in using stl string inside the idl.


    I tried dynamic arrays but i am unable to persist the pointer from heap corruption... e.g. here is my idl code

    Code:
    interface myinterface
    {
    
    void RPC_GetGroupStatusEx([out] char ** szXMLString);
    
    }

    server implemented code

    Code:
    void RPC_GetGroupStatusEx(unsigned char ** szXMLString)
    {
         
       CString strXmlRawData = GetSomeXmlData(); //it return xml string
    
        unsigned char* dyn = new unsigned char[strXmlRawData.GetLength()];
    
        sprintf((char*)dyn,"%s", strXmlRawData.GetBuffer());
    	
       *szXMLString =dyn;
    }

    client caller code

    Code:
    unsigned char *ms = NULL; 
    
    //i have tried even initialized pointer by sending it to the server but it also gave me heap corruption , also i have used address of pointer but same result
    
              RpcTryExcept
    	   {
    		
    		   RPC_GetGroupStatusEx(&ms);
    
    	   }
    	   RpcExcept(1)
    	   {
    		   int a = RpcExceptionCode();
    		  
    		  std::cerr << "Runtime reported exception " << RpcExceptionCode()
    					<< std::endl;
    	   }
    	   RpcEndExcept


    it always crash at the server side code after leaving that function , one more thing is RPC server is on the different machine. Every other functions with data types works fine except string.


    Please guide me what i am doing wrong in the code? How can i use stl string inside the idl file ?


    Regards
    Last edited by Wolvorine; February 4th, 2011 at 01:24 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured