| troutguy (22) | |
|
I'm using sockets in a C++ forms application and it is talking to a native C++ DLL that uses winsock send() recv(). I am needing to convert a array<byte>^ to a String^ as the Socket->Receive() and Socket->Send() methods use a byte array as the buffer for sending and receiving. I need an explicit process to convert the byte array buffer to a string for the receive, and then do the opposite for going back on the Send side. Any help would be great... Thanks, T- | |
|
|
|
| modoran (1099) | |
| http://stackoverflow.com/questions/11355743/converting-stdstring-or-string-to-byte-array-in-c-cli | |
|
|
|
| troutguy (22) | |||||
|
thanks for the link modoran... i used the method for conversion shown in the topic however I get a garbled mess of characters on the other end after sending: the code i used to convert is:
on the receiving end the process is unmanaged and uses winsock:
I receive the correct number of bytes but the original string ""Got the message\0" ends up as a mess of characters... any advice on how to remedy this...I'll bet i'm missing something pretty simple. Thnaks, T- | |||||
|
|
|||||
| troutguy (22) | |
| I figured it out...by using a simple NetworkStream and encoding the byte arrays i can send to and receive from the native winsock using .net sockets... | |
|
|
|