code: def create_socks_endpoint(self, reactor, socks_config):
          
  
          yield self.post_bootstrap
  
          if socks_config is None:
              if len(self.SocksPort) == 0:
                  raise RuntimeError(
                      "socks_port is None and Tor has no SocksPorts configured"
                  )
              socks_config = self.SocksPort[0]
          else:
              if not any([socks_config in port for port in self.SocksPort]):
                  # need to configure Tor
                  self.SocksPort.append(socks_config)
                  try:
                      yield self.save()
                  except TorProtocolError as e:
                      extra = ''
                      if socks_config.startswith('unix:'):
                          # XXX so why don't we check this for the
                          # caller, earlier on?
                          extra = '\nNote Tor has specific ownership/permissions ' +\
                                  'requirements for unix sockets and parent dir.'
                      raise RuntimeError(
                          "While configuring SOCKSPort to '{}', error from"
                          " Tor: {}{}".format(
                              socks_config, e, extra
                          )
                      )
  
          defer.returnValue(
              _endpoint_from_socksport_line(reactor, socks_config)
          )
docs: Creates a new TorSocksEndpoint instance given a valid
          configuration line for ``SocksPort``; if this configuration
          isn't already in the underlying tor, we add it. Note that this
          method may call :meth:`txtorcon.TorConfig.save()` on this instance.
  
          Note that calling this with `socks_config=None` is equivalent
          to calling `.socks_endpoint` (which is not async).
  
          XXX socks_config should be .. i dunno, but there's fucking
          options and craziness, e.g. default Tor Browser Bundle is:
          ['9150 IPv6Traffic PreferIPv6 KeepAliveIsolateSOCKSAuth',
          '9155']
  
          XXX maybe we should say "socks_port" as the 3rd arg, insist
          it's an int, and then allow/support all the other options
          (e.g. via kwargs)
  
          XXX we could avoid the "maybe call .save()" thing; worth it?
          (actually, no we can't or the Tor won't have it config'd)