FacebookTwitterGoogle+Share

mxml, google, and sockets

Trying MXML always seemed just a little scary; All those tags everywhere, while just writing the class files was so nice and familiar. I finally did it, though. Yes. Yes, I really did. Not only did I use MXML for the first time, but took that trend of trying new things and clambered up and out of the sandbox into the open air. Neither were as frightening as I had hoped. They were actually kind of cool. I’ve even used them since.

karl sent me to google app engine. It looked slightly amazing.

For work, I was using sockets in PHP. The code worked fine locally: it would connect to the RPC Server and retrieve the appropriate xml, parse it, and take whatever action applicable. Sadly that was far from the case when run on the actual web server.

It only ever retrieved partial data.

If I called read twice, it would sit there forever (or until it timed out) waiting for data.

If I sent a random character and read from the socket, it retrieved more of the data. Which was fine, as long as I was willing to guess at how much data each response would bring.

Again, not the case.

string socket_read  ( resource $socket  , int $length  [, int $type  ] )

PHP_BINARY_READ (Default) – use the system recv() function. Safe for reading binary data.
PHP_NORMAL_READ – reading stops at n or r.

I ended up switching to the other read (the one that ends on n or r) and calling it in an infinite loop (breaking when the line contained the close tag).
Thankfully, that seemed to work.

I have to give 14 days notice before I leave. Which works out well when they don’t tell me about rent increases until seven days past that.

 

Comments