Goal:

I am writing a socket server/client program (c++ is the server, python is the client) to send xml strings that carry data. My goal is to be able to receive an xml message from c++ in Python via socket.

**Method**

VS2013 pro
Python 2.7.2 via Vizard 4.1

1) socket communication is created just fine, no problems. I can send/receive stuff

2) after communications are initialized, c++ begins creating xml objects using Cmarkup

3) c++ converts the xml object to std::string type 

4) c++ sends the std::string over the stream to Python

**Problem:**

The "string" received in python from C++ is interpreted as garbage symbols (not trying to offend, someone may have strong feelings for them, I do not ;) that look like symbols you'd see in notepad if you opened a binary file. This is not surprising, since data sent over the stream is binary.

What I cannot figure out is how to get Python to make sense of the stream. 

**Failed Attempts to fix:**

1) made sure that VS2013 project uses Unicode characters

2) tried converting stream to python string and decoding it string.decode()

3) tried using Unicode() 

4) also tried using binascii() methods to get something useful, small improvement but still not the same characters I sent from c++

If anyone can lend some insight on why this is happening I'd be most grateful. I have read several forums about the way data is sent over sockets, but this aspect of encoding and decoding is still spam-mackerel-casserole to my mind. 

Here's the server code that creates xml, converts to string, then sends

```
        MCD_CSTR rootname("ROOT");//initializes name for root node
        MCD_CSTR Framename("FRAME");//creates name for child node
        CMarkup xml;//initializes xml object using Cmarkup method
        xml.AddElem(rootname);//create the root node
        xml.IntoElem();//move into it
        xml.AddElem(Framename, MyClient.GetFrameNumber().FrameNumber);//create child node with data from elsewhere, FrameNumber is an int

        CStringA strXML = xml.GetDoc();//convert the xml object to a string using Cmarkup method
        std::string test(strXML);//convert the CstringA to a std::string type
        std::cout << test << '\n';//verify that the xml as a string looks right
        std::cout << typeid(test).name() << '\n';//make sure it is the right type

        iSendResult = send(ClientSocket, (char *)&test, sizeof(test), 0);//send the string to the client

```

Here is the code to receive the xml string in Python:

```
while 1:
    data = s.recv(1024)#receive the stream with larger than required buffer
    print(data)#see what is in there
    if not data: break#if no data then stop listening for more

```