I have a program in C ++ that sends a socket of 23723 bytes to a flash player in one "shot".
A flash player sometimes receives two packets of size 17520 and 6203, and in other cases it receives one packet of 23723.
EDIT: There seems to be no way to get the total number of bytes associated with flash send data. This will make it very difficult to create a loop to recover a broken package.
I thought TCP should have recombined the packets correctly, and I am having difficulty recombining them.
This is my flash receive handler:
var socket:Socket = new Socket(); socket.addEventListener(Event.CONNECT, socketConnectHandler); socket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataReceivedHandler); socket.connect("127.0.0.1", 7445); socket.writeUTFBytes("hi"); private function socketDataReceivedHandler(event:ProgressEvent):void { var socket:Socket = event.target as Socket; trace(socket.bytesAvailable); var data:ByteArray = new ByteArray(); socket.readBytes(data); }
Command:
trace(socket.bytesAvailable);
it will print 23723 from time to time, and at another time it will print 17520 quickly and then 6203. The total size is just examples and can be changed for each sending socket. Also, many sockets can be sent or received at the same time, so split packets can be mixed. In C ++, I could determine what the total size of the data sent was, even if I had not yet received all the data sent.
source share