extracted the clock socket communication into a separate file for better encapsulation and so that I can test it on its own.