moved watchSocket to lib