Problem socket when closed socket that is opened again

1)I have a working socket connection.
2) I send and received data trough that connection (once), which is detected via onSocketData
3) I closed socket
4) I open socket again
5) onSocketData is called twice.
6) If I close/open socket socket is done again, onSocketData is called twice again, with socket.dataAvailable doubled in first call.

Here’s a code of onSocketData handler:

		private function onSocketData( event:ProgressEvent ):void //handles data
		//message length
		var len	:uint;
			while ( m_socket.bytesAvailable != 0 )
				//take a message len		
				len = m_socket.readUnsignedShort() - 2;
				//rest of message
				m_socket.readBytes(m_input, 0, len);

				//decouple header from data
				m_input = m_msgDecoupler.decouple(m_input);