More robust socket data parser