Main class, first approach. Support for socket state switching.