moved structs to main constructor to solve error with socket setting.