Hi,
To prevent Mac from sleeping:
Open Terminal
Run sudo pmset -a sleep 0
Then also follow below tasks.
ifconfig
(To verify whether en0 or en1 active for wireless)
Under terminal,
cd /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources
sudo ./airport en1 prefs DisconnectOnLogout=NO
Also, under the terminal, make following changes
./airport en0 prefs
Disconnecto logout=NO
JoinModeFallback=DoNothing
RememberRecentNetworks=YES
RequireAdminIBSS=NO
RequireAdminPowerToggle=NO
AlloweLegacyNetworks=NO
WoWEnabled=NO