Hi I have the next issue, why when I send data like this
uint8_t buffer[11] = "I send this";
NSInteger nwritten = [outputStream write:buffer maxLength:sizeof(buffer)];
if (-1 == nwritten) {
NSLog(@"Error writing to stream %@: %@", outputStream, [outputStream streamError]);
}else{
NSLog(@"Wrote %i bytes to stream %@.", nwritten, outputStream);
}
in the other side in the java socket server
connection = new Socket(Constants.HOST, Constants.CHAT_LISTENER_PORT);
_in = new DataInputStream(connection.getInputStream());
String data = _in.readUTF();
But nothing appear like as if it had not sent anything.
I read to much and I found the problem is from platforms because java byte works with big-endians and iOS with little-endians but I don’t found information about how do to this.
uint8_t buffer[11] = “I send this”; to big-Endians format
Please heellppp, thanks.
Sorry my English is very but there is nothing in spanish :/ thaks.
On the server side in the next Line in java code:
this .readUTF() expect a UTF java native type what is not the same with objective-c type, and the solution was send the string codifying in UTF native java like this.
And the Magic come from: