Refactor socket init and add data type Server