I am dealing with this same problem, but I get the solution from another way not sure how secure it is.
clen = new char[2];
*(unsigned short *)clen = m_length;
User Profile
Collapse
-
Short to char array and back.
Hello,
I been working on an application that need to build a data package to send it over the network, I have an unsigned short as the data length, this is two bytes.
On the server side I am working on C# and on the client side I am working on C++.
What I precisely need if to mimic some functionality I have on C# provided by the .net Framework.
System.BitConve rter.GetBytes(v alue)
... -
Hello
I am getting the data from C# on the C++ side this way
err = recv(m_ClientSo cket, Buff, 65535, 0);
err is now 6,
and the 65535 is the max my data can be.
so, on this Buff variable, strlen do not apply? how I can get the data this way?
I need to put the first 2 bytes, into a short, the third and forth into char[2], and the other 2 in 2 char variables, in the case that...Leave a comment:
-
Byte 0 problem over socjets C++ and C#
Hello
I am fighting to sync a C++ client with a C# server, I have managed to create a byte array in C++ stored as char* to be sent over the network to the server written in C#.
on the C# side, I get the data on a byte array which I successfully convert to an object with similarities to the object the data came from in C++, then I construct an object with the reply, encode it to a byte array and I send it back to the... -
bytes manipulation in C++
Hello all.
I am mostly a C# developer, and I am working on a research project which involves networking between a server written in C# and the client written in C++.
I have defined a protocol that will move info to/from the server, C# socket functions gets bytes from the network, while C++ char*.
So I am running in problem to make C++ to handle and convert values to bytes, I know there is no naive type...
No activity results to display
Show More
Leave a comment: