refactored rest & sock (client&server)