I’m trying to use the openfl.net.Socket class but having problems on Android. Things work fine on flash. Is there anything different that i have to do for android? I’m currently just creating ByteArrays and using Socket writeBytes method and listening for ProgressEvent.SOCKET_DATA for data on the socket.
I’m pretty sure that the OpenFL socket class uses sys.net.Socket under the hood, perhaps someone could take a look if things are not behaving quite as expected
The problem might be the creation of the bytearray. It looks like whenever i write something to it using writeByte that value appears to be 0, so in the end the bytearray is full of 0’s. Again not sure why this doesn’t work since it works for the flash target.
Well, it isn’t too complicated. I create a openfl.net.Socket.
add listener for Event.CONNECT, ProgressEvent.SOCKET_DATA, and the errors.
I then call socket.connect(host, port). It connects, since my eventlistener is called.
I then get some data from the host which i them try to send some values to the host. This is where it fails.
I create an openfl.utils.ByteArray like so var byteArr:ByteArray = new ByteArray(); Then i start writing to it like so byteArr.writeByte(0xFF); etc… with other values.
Finally i call socket.writeBytes(byteArr) and socket.flush().
That is all that i’m trying to do. When i print out the values of the bytearray they are all 0. So i think think the problem is in the bytearray possible.