Gets accepted clients from the queue object and sets up the client socket.
        The client can then be found in the clients dictionary with the socket object
        as the key.
492949
def _subthread_handle_accepted(self, client):
        

        conn, addr = client
        if self.handle_incoming(conn, addr):
            logging.info('Accepted connection from client: {}'.format(addr))
            conn.setblocking(False)
            self.clients[conn] = addr
            self.register(conn)
        else:
            logging.info('Refused connection from client: {}'.format(addr))
            self.disconnect(conn)
743348
function Client(opts) {
    if (!(this instanceof Client)) {
        return new Client(opts);
    }

    var options = {};

    // If single connection provided, array-ify it
    if (typeof opts === 'string') {
        options.hosts = [opts];
        opts = options;
    } else if (typeof opts === 'undefined') {
        opts = {};
    } else if (_.isArray(opts)) {
        options.hosts = opts;
        opts = options;
    }

    _.defaults(opts, {
        autodiscover: false,
        bufferBeforeError: 1000,
        disabled: false,
        hosts: null,
        reconnect: true,
        onNetError: function onNetError(err) { console.error(err); },
        queue: true,
        netTimeout: 500,
        backoffLimit: 10000,
        maxValueSize: 1048576
    });

    // Iterate over options, assign each to this object
    R.keys(opts).forEach(function(key) {
        this[key] = opts[key];
    }, this);

    if (this.queue) {
        this.buffer = new Immutable.List();
    }

    debug('Connect options', opts);
    this.connect();
}
1128640
def get_client_data(self, client):
        
        data = self._request('GET', '/clients/{}'.format(client))
        return data.json()
59692
protected void setupQueue() throws IOException {
		if (queueName != null) {
			channel.queueDeclare(queueName, false, false, false, null);
		}
	}
314883
def create(clients_num, clients_host, clients_port, people_num, throttle):
    
    res = []
    for number in range(clients_num):
        sc = EchoClient({
            'id': number,
            'listen_bind_ip': clients_host,
            #'multicast_bind_ip': "127.0.0.1",
            'listen_port': clients_port + number
        })
        people = []
        for person_number in range(people_num):
            people.append(Person(id=person_number))
        wrapper = WrapperEchoClient({
            'client': sc,
            'people': people,
            'throttle': throttle
        })
        res.append(wrapper)

    return res, cmd_line
32381
def connect(self):
        
        self.connection = pika.BlockingConnection(BLOCKING_MQ_PARAMS)
        self.client_queue = ClientQueue()
        self.input_channel = self.connection.channel()

        self.input_channel.exchange_declare(exchange=self.INPUT_EXCHANGE,
                                            type='topic',
                                            durable=True)
        self.input_channel.queue_declare(queue=self.INPUT_QUEUE_NAME)
        self.input_channel.queue_bind(exchange=self.INPUT_EXCHANGE, queue=self.INPUT_QUEUE_NAME)
        log.info("Bind to queue named '%s' queue with exchange '%s'" % (self.INPUT_QUEUE_NAME,
                                                                        self.INPUT_EXCHANGE))
221455
@Override
    protected Client getClient(String apiKey) throws IOException {
        Client client;
        synchronized (mutex) {
            client = clientCache.get(apiKey);
        }

        if (client == null) {
            client = super.getClient(apiKey);
            synchronized (mutex) {
                if (client != null) {
                    clientCache.put(apiKey, client);
                }
            }
        }

        return client;
    }
239014
def get_clients(self):
        
        public = self.channels['public']
        private = self.channels['private']
        return dict(public.items() + private.items())
657268
def clients(self):
        ''''''
        clients_response = self.get_request('clients/')
        return [Client(self, cjson['client']) for cjson in clients_response]
224632
def client(self):
        
        if not hasattr(self, "_client"):
            self._client = connections.get_connection("default")
        return self._client
840264
def _accept_loop(self):
        """"""
        self._listening_sock.setblocking(0)
        while not self._stopped and not _shutting_down:
            try:
                # Wait a short time to accept.
                if select.select([self._listening_sock.fileno()], [], [], 1):
                    client, client_addr = self._listening_sock.accept()
                    client.setblocking(True)
                    self._log('connection from %s' % format_addr(client_addr))
                    server_thread = threading.Thread(
                        target=functools.partial(
                            self._server_loop, client, client_addr))

                    # Store weakrefs to the thread and socket, so we can
                    # dispose them in stop().
                    self._server_threads[server_thread] = None
                    self._server_socks[client] = None

                    server_thread.daemon = True
                    server_thread.start()
            except socket.error as error:
                if error.errno not in (
                    errno.EAGAIN, errno.EBADF, errno.EWOULDBLOCK):
                    raise
            except select.error as error:
                if error.args[0] == errno.EBADF:
                    # Closed.
                    break
                else:
                    raise
351574
@Override
  public boolean accept(SocketBar socket)
    throws IOException
  {
    JniSocketImpl jniSocket = (JniSocketImpl) socket;

    if (_fd == 0)
      throw new IOException("accept from closed socket");

    return jniSocket.accept(this, _fd, _socketTimeout);
  }
1354544
function Client(key, options, GenericSocket) {
	var self = this,
		genericSocket = GenericSocket || undefined;
	
	self.connection = IrcSocket(options, genericSocket);
	self.options = options;
	self.supported = Helper.defaultSupported();
	self.key = key;

	self._connecting = false;
	self._queueId = QueuePool.queueLength(options.server);
	self._nick = options.nick;
	self._hostname = options.hostname;
	self._user = options.user;
	self._oper = false;
	self._requestedDisconnect = false;
	self._sendRegisteredTimer;
	self._pings = 0;
	self._retryTimer = null;
	self._retryCount = 0;
	self._capCount = 0;
	self._nickModifier = 0;
	self._timedOut = false;
	self._cap = {};
	self._data = {
		user: {},
		channel: {},
		server: {}
	};
	// setup a bunch of variables to manage the state of the connection

	self.connection.setTimeout(30000, function() {
		var seconds = Math.floor((+new Date()) / 1000);
		if ((seconds - self._lastTime) >= 5 * 60) {
			self._timedOut = true;
			self.disconnect();
		} else {
			self.raw(['PING', new Date().getTime().toString()]);
		}
	});

	self.queueConnect = _.wrap(self.connection.connect, function(fn, qid) {
		QueuePool.queueJob(self.options.server, qid, self.key, function() {
			fn.call(self.connection);
			self._connecting = true;

			Events.emit([self.key, 'connecting'], {
				nickname: self._nick,
				username: self.options.user,
				server: self.options.server,
				port: self.options.port,
				localPort: self.connection.impl.localPort
			});
			// emit a connecting event
		});
	});
	// setup queueConnect

	self.queueConnect(self._queueId);
	// connect the server

	self.connection.on('connect', self._connectEvent.bind(self));
	self.connection.on('close', self._closeEvent.bind(self));
	self.connection.on('error', function() { });
	self.connection.on('data', self._parseLine.bind(self));
	// event handlers
}
299468
def server_bind(self):
        
        TCPServer.server_bind(self)
        host, port = self.socket.getsockname()[:2]
        self.server_port = port
        try:
            self.server_name = socket.getfqdn(host)
        except ValueError:
            # Use the local host name in case of error, like CPython does
            self.server_name = socket.gethostname()
332200
private ClientSocket connect()
  {
    if (_maxConnections <= _activeCount.get() + _startingCount.get()) {
      if (log.isLoggable(Level.WARNING)) {
        log.warning(this + " connect exceeded max-connections"
                    + "\n  max-connections=" + _maxConnections
                    + "\n  activeCount=" + _activeCount.get()
                    + "\n  startingCount=" + _startingCount.get());
      }
      
      return null;
    }

    _startingCount.incrementAndGet();

    State state = _state;
    
    if (! state.isInit()) {
      _startingCount.decrementAndGet();
      
      IllegalStateException e = new IllegalStateException(L.l("'{0}' connection cannot be opened because the server pool has not been started.", this));

      log.log(Level.WARNING, e.toString(), e);

      throw e;
    }
    
    if (getPort() <= 0) {
      return null;
    }
    
    long connectionStartTime = CurrentTime.currentTime();

    try {
      ReadWritePair pair = openTCPPair();
      ReadStreamOld rs = pair.getReadStream();
      rs.setEnableReadTime(true);
      
      //rs.setAttribute("timeout", new Integer((int) _loadBalanceSocketTimeout));

      _activeCount.incrementAndGet();
      
      _connectCountTotal.incrementAndGet();

      ClientSocket stream = new ClientSocket(this, _streamCount++,
                                               rs, pair.getWriteStream());

      if (log.isLoggable(Level.FINER))
        log.finer("connect " + stream);

      if (_firstSuccessTime <= 0) {
        if (_state.isStarting()) {
          if (_loadBalanceWarmupTime > 0)
            _state = State.WARMUP;
          else
            _state = State.ACTIVE;

          _firstSuccessTime = CurrentTime.currentTime();
        }

        if (_warmupState < 0)
          _warmupState = 0;
      }

      return stream;
    } catch (IOException e) {
      if (log.isLoggable(Level.FINEST))
        log.log(Level.FINEST, this + " " + e.toString(), e);
      else
        log.finer(this + " " + e.toString());

      failConnect(connectionStartTime);

      return null;
    } finally {
      _startingCount.decrementAndGet();
    }
  }
431962
def get_request(self):
        
        # Accept the client
        client_socket, client_address = self.socket.accept()

        if ssl is not None and self.cert_file:
            # Setup an SSL context to accept clients with a certificate
            # signed by a known chain of authority.
            # Other clients will be rejected during handshake.
            context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
            try:
                # Force a valid/signed client-side certificate
                context.verify_mode = ssl.CERT_REQUIRED

                # Load the server certificate
                context.load_cert_chain(
                    certfile=self.cert_file,
                    keyfile=self.key_file,
                    password=self.key_password,
                )

                if self.ca_file:
                    # Load the given authority chain
                    context.load_verify_locations(self.ca_file)
                else:
                    # Load the default chain if none given
                    context.load_default_certs(ssl.Purpose.CLIENT_AUTH)
            except Exception as ex:
                # Explicitly log the error as the default behaviour hides it
                _logger.error("Error setting up the SSL context: %s", ex)
                raise

            try:
                # SSL handshake
                client_stream = context.wrap_socket(
                    client_socket, server_side=True
                )
            except ssl.SSLError as ex:
                # Explicitly log the exception before re-raising it
                _logger.warning(
                    "Error during SSL handshake with %s: %s", client_address, ex
                )
                raise
        else:
            # Nothing to do, use the raw socket
            client_stream = client_socket

        return client_stream, client_address
707261
def queue_bind(self, queue, exchange, routing_key, arguments=None):
        """"""
        return self.channel.queue_bind(queue=queue,
                                       exchange=exchange,
                                       routing_key=routing_key,
                                       arguments=arguments)