Moved socket related codes inside Thread to avoid crashes in AudioReceiver