code for creating a server connection: This is using the a generic version of the reactor pattern. more modifications will be made later