Setup a socket and process events