views:

295

answers:

2

I am currently working on a Flash socket client for a pre-existing service/standard. The service uses TCP flow control to throttle itself and the Flash socket is reading in everything as fast as it can despite not being able to process it as fast as it's being taken in. This causes the bytesAvailable on the socket to keep increasing and the server never knows that the client has fallen behind.

In short, is there any way to limit the size of bytesAvailable for a Flash Socket object or throttle it in some other way?

Note: Rewriting the server isn't a viable option at the current time as it's a standard and the client's utility drops immensely if server-side changes are needed

A: 

I don't think it is possible. There is no low-level API in AS3 that can manipulate with bytes on TCP level. But you can implement throttle on higher level. For example: before you put bytes into Socket's byteArray, check how many data you have put there for the last couple seconds. If this value is too high - postpone operation.

Wizzard
Unfortunately, I can't touch the server portion due to implementation restraints. I'm trying to avoid using a relay/proxy server of some kind, but it's looking inevitable.
Jeremy Stanley
A: 

After research I've found that the Actionscript Socket class will start throttling when CPU is maxed out on the system (likely due to running out of resources/slow response times).

This has actually solved my problem as I've written the code such that it strikes a balance between how many frames per second the app "wants" and how many bytesAvailable are in the socket. If bytesAvailable is too high the app will process non-stop and drive CPU to 100%, ultimately causing the socket to slow down.

Jeremy Stanley