                             {
 							    channel.dispatchEvent(MessageEvent.createEvent(MessageEvent.MESSAGE, message));
                             }
+                            // We've just finsihed the one point in the parse loop where we step outside of local control.
+                            // The connection may now be closed, so check for this case here.
+                            if (state == CLOSED_STATE)
+                                return;
+                            
                         }
 						state = RESET_BUFFER_STATE;
                     }

            result += digit * powerOfSixteen;
        }
        return result;
    }
    
    /**
     *  Helper method to reset parser to initial state.
     */
    private function resetParserState():void
    {
        state = INIT_STATE;
        chunkBuffer = null;
        hexChunkSize = null;
        dataBytesToRead = -1;
        dataOffset = 0;
    }

    /**

    private static const SKIP_STATE:int = 5;
    private static const DATA_STATE:int = 6;
    private static const RESET_BUFFER_STATE:int = 7;
    private static const CLOSED_STATE:int = 8;

    //--------------------------------------------------------------------------
    //
