Implement connectToService and add server mode to SocketAdaptor.