-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
toArrayBuffer question #56
Comments
When sending binary data over the network and no binary-safe mechanism is available, you should encode it to base64 prior to transmission and decode it on the other end. Regarding the invalid argument error I have no idea yet. Can you explain the difference between the two |
I have solved this problem. arrayBuffer can't converted to Uint16Array, because the number of bytes of data buffer may be singular, such as arrayBuffer byteLength is 61, it can only converted to Uint8Array, but if arrayBuffer byteLength is 62 or other even, it can converted to Uint16Array or Uint8Array. Actually, We do not know the length of the buffer is even or base. So, we shouldn't use Uint16Array. String.fromCharCode(), this function will returns a string created by using the specified sequence of Unicode values.but, in my server, it unacceptable string has been encoded, so, i set string to latin1 before i send it to server. So, solve all the problems. |
Ucchen. I am having a similar problem with my code as well. Do you by anychance have the code that you used to send the str via a socket. I am trying to do what you are doing but my python script is not recognizing the string that I am sending to it. |
doesn't recognizing the string? can you post more detail? |
var commandmessage = new MCM ({
chrome.sockets.udp.send(socketId, byteBuffer, "0.0.0.0", 9994, function(sendInfo) { class MyUDPHandler(SocketServer.BaseRequestHandler):
if name == 'main':
|
Hello!
here is my test code.
but, get an error when i new Uint16Array. the log said that arrayBuffer is a invalid arguments. why arrayBuffer is an invalid arguments? but, if i do this var _uint8Array = new Uint8Array(arrayBuffer), it is ok. what's wrong of that? arrayBuffer is a ArrayBuffer? if arrayBuffer is a ArrayBuffer, why i can't new Uint16Array?
here is my second test code
server receive such struct
id: 16706
name: "abc"
id's data isn't right, but string data is ok.
why?
The text was updated successfully, but these errors were encountered: