Establish the actual TCP connection to Flickr
515203
def _connectToFlickr(self):
        """"""

        if self.connected_to_flickr:
            logger.debug("Already connected to flickr")
            return True

        logger.debug("Connecting to flickr")
        # Do flickr authentication
        _flickr = flickrapi.FlickrAPI(api_key, api_secret,format='etree')
        try:
            (token, frob) = _flickr.get_token_part_one(perms='delete')
        except:
            print("Couldn't connect to flickr")
            return False

        if not token: raw_input("Press ENTER after you authorized this program")
        _flickr.get_token_part_two((token, frob))

        self.flickr=_flickr;
        
        self.connected_to_flickr=True

        return True
1052508
function FlickrImageDownloader () {
	var that = this;
	
	that.url = '';
	that.delay = 500;
	that.downloadFolder = '';

	that.paths = {};
	that.paths.base = 'https://www.flickr.com';
	that.paths.photostream = 'photos/!username';
	that.paths.set = that.paths.photostream + '/sets';
	that.paths.favorites = that.paths.photostream + '/favorites';

	that.image = {};
	that.image.dataAttr = 'deferSrc';
	that.image.selector = 'div#photo-display-container img.pc_img';	
	
	// Events constructor
	events.EventEmitter.call(that);

	// Setup listeners
	that.on('pageCountLoaded', function () {
		console.log('Event::pageCountLoaded');
		that.getImageUrls();
	});

	that.on('imageUrlsLoaded', function () {
		console.log('Event::imageUrlsLoaded');
		that.downloadImages();
	});

	that.on('downloadFinished', function (imageUrl) {
		console.log('Event::downloadFinished(' + imageUrl + ')');
	});

	that.on('allDownloadsFinished', function () {
		console.log('Event::allDownloadsFinished');
	});

	that.on('error', function (functionName, error) {
		console.log('Event::Error (' + functionName + ')', error);
	});
}
1297421
def connect(self):
        """"""
        self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self._socket.settimeout(self._connect_timeout)
        SocketError.wrap(self._socket.connect, (self.host, self.port))
        self._socket.settimeout(None)
        self._socket_file = self._socket.makefile('rb')
1234042
function (port, debug) {
  this.port = port || 'tcp://127.0.0.1:13674';
  this.debug = debug || false;
  this.socket = zeromq.socket('router');
  this.socket.identity = 'zmqrpc-'+process.pid;
  this.rpc = undefined;
}
988862
def connection_made(self, transport):
        """"""
        self.logger.info('Connection made at object %s', id(self))
        self.transport = transport
        self.keepalive = True

        if self._timeout:
            self.logger.debug('Registering timeout event')
            self._timout_handle = self._loop.call_later(
                self._timeout, self._handle_timeout)
842917
def tcp(self):
        
        ipproto, proto_start = self.protocol
        if ipproto == Protocol.TCP:
            return TCPHeader(self, proto_start)
1110814
def _connect(self):

        '''
            
        '''

        if self.connection_type.lower() == 'tcp':
            self.connection = sockets.setup_tcp_socket(self.location, self.port)

        elif self.connection_type.lower() == 'unix':
            self.connection = sockets.setup_domain_socket(self.location)

        return
129060
function _connect(&$fp)
    {
        if (!empty($this->proxy_host) && !empty($this->proxy_port)) {
            $this->_isproxy = true;

            $host = $this->proxy_host;
            $port = $this->proxy_port;

            if ($this->scheme == 'https') {
                trigger_error("HTTPS connections over proxy are currently not supported", E_USER_ERROR);
                exit;
            }
        } else {
            $host = $this->host;
            $port = $this->port;
        }

        $this->status = 0;

        $context_opts = array();

        if ($this->scheme == 'https') {
            // if cafile or capath is specified, enable certificate
            // verification (including name checks)
            if (isset($this->cafile) || isset($this->capath)) {
                $context_opts['ssl'] = array(
                    'verify_peer' => true,
                    'CN_match' => $this->host,
                    'disable_compression' => true,
                );

                if (isset($this->cafile))
                    $context_opts['ssl']['cafile'] = $this->cafile;
                if (isset($this->capath))
                    $context_opts['ssl']['capath'] = $this->capath;
            }
                    
            $host = 'ssl://' . $host;
        }

        $context = stream_context_create($context_opts);

        if (version_compare(PHP_VERSION, '5.0.0', '>')) {
            if($this->scheme == 'http')
                $host = "tcp://" . $host;
            $fp = stream_socket_client(
                "$host:$port",
                $errno,
                $errmsg,
                $this->_fp_timeout,
                STREAM_CLIENT_CONNECT,
                $context);
        } else {
            $fp = fsockopen(
                $host,
                $port,
                $errno,
                $errstr,
                $this->_fp_timeout,
                $context);
        }

        if ($fp) {
            // socket connection succeeded
            return true;
        } else {
            // socket connection failed
            $this->status = $errno;
            switch ($errno) {
                case -3:
                    $this->error = "socket creation failed (-3)";
                case -4:
                    $this->error = "dns lookup failure (-4)";
                case -5:
                    $this->error = "connection refused or timed out (-5)";
                default:
                    $this->error = "connection failed (" . $errno . ")";
            }
            return false;
        }
    }
601167
def _configure_sockets(self, config, with_streamer=False, with_forwarder=False):
        
        rc_port = config.get('rc_port', 5001)

        self.result_collector.set_hwm(0)
        self.result_collector.bind("tcp://*:{}".format(rc_port))

        self.poller.register(self.result_collector, zmq.POLLIN)
1243954
def connect(self):
        
        HTTPConnection.connect(self)
        self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
1198181
def wireshark(pktlist, wait=False, **kwargs):
    
    return tcpdump(pktlist, prog=conf.prog.wireshark, wait=wait, **kwargs)
1076783
function TcpConnect (socket) {
    this.count ++;    // increment client count inside this server
    socket.uid = "Socket://" + socket.remoteAddress +":" + socket.remotePort;
    socket.controller = this.controller;
    socket.adapter   = this.adapter;
    socket.controller.Debug(4, "N°:%d Server=[%s] Client: [%s]"
             ,this.count,this.uid,socket.uid);            
        
    // attach new device object to client socket
    socket.device = new TcpClient (socket);
    
    // notify adapter that it has a new client device connected
    if (socket.adapter.ClientConnect (socket) === -1) {
        try {socket.end();} catch(e){};
        return;
    }
  
    // send any received data to device parser
    socket.on(this.evtname, function(buffer) {
	    socket.controller.Debug(7, "%s Data=[%s]", socket.device.uid, buffer);
        // call adapter specific method to process messages
        socket.adapter.ParseBuffer(socket, buffer);
    });
    
    // On error close socket
    socket.on('error', function (err) {
        socket.controller.Debug(3, "%s ERROR=[%s]", socket.device.uid, err);
        this.adapter.ClientQuit(socket);
        try {socket.destroy();} catch(e){};
    });
        
    // Remove the device from gateway active device list and notify adapter for eventual cleanup
    socket.on('end', function () {
	socket.controller.Debug(4, "SockClient Quit devid=%s uid=%s", socket.device.devid, socket.device.uid);
        this.adapter.ClientQuit(socket);
    });
    
}
664327
def _connect(self):
        
        framer = None
        if self._framer == 0:  # Socket Framer
            framer = ModbusSocketFramer
        elif self._framer == 1:  # RTU Framer
            framer = ModbusRtuFramer
        elif self._framer == 2:  # ASCII Framer
            framer = ModbusAsciiFramer
        elif self._framer == 3:  # Binary Framer
            framer = ModbusBinaryFramer

        if self._protocol == 0:  # TCP
            if self._framer is None:  # No Framer
                self.slave = ModbusTcpClient(self._address, int(self._port))
            else:
                self.slave = ModbusTcpClient(self._address, int(self._port), framer=framer)
        elif self._protocol == 1:  # UDP
            if self._framer is None:  # No Framer
                self.slave = ModbusUdpClient(self._address, int(self._port))
            else:
                self.slave = ModbusUdpClient(self._address, int(self._port), framer=framer)
        elif self._protocol in (2, 3, 4):  # serial
            method_list = {2: 'ascii', 3: 'rtu', 4: 'binary'}
            self.slave = ModbusSerialClient(
                method=method_list[self._protocol],
                port=self._port,
                stopbits=self._stopbits,
                bytesize=self._bytesize,
                parity=self._parity,
                baudrate=self._baudrate,
                timeout=self._timeout)
        else:
            raise NotImplementedError("Protocol not supported")
        status = self.slave.connect()
        return status
1133896
async def connect(self):
        """"""
        tcp_client = TCPTransport(self.frame_received_cb, self.connection_closed_cb)
        self.transport, _ = await self.loop.create_connection(
            lambda: tcp_client,
            host=self.config.host,
            port=self.config.port,
            ssl=self.create_ssl_context())
        self.connected = True
940097
function TcpStreamConnect () {
        this.simulator.Debug (3, 'Dispatcher connected to %s:%s', simulator.opts.host, simulator.opts.port);
        ActiveClients[this] = this;  // register on remote server in active socket list
    }
338758
def openRtpPort(self):
    """"""
    #-------------
    # TO COMPLETE
    #-------------
    # Create a new datagram socket to receive RTP packets from the server
    # self.rtpSocket = ...


    # Set the timeout value of the socket to 0.5sec
    # ...
    self.rtpSocket.settimeout(0.5)
#   try:
      # Bind the socket to the address using the RTP port given by the client user
      # ...
#   except:
#     tkMessageBox.showwarning('Unable to Bind', 'Unable to bind PORT=%d' %self.rtpPort)

    try:
      #self.rtpSocket.connect(self.serverAddr,self.rtpPort)
      self.rtpSocket.bind((self.serverAddr,self.rtpPort))   # WATCH OUT THE ADDRESS FORMAT!!!!!  rtpPort# should be bigger than 1024
      #self.rtpSocket.listen(5)
      print("Bind RtpPort Success")

    except:
      tkinter.messagebox.showwarning('Connection Failed', 'Connection to rtpServer failed...')
289064
def connectToServer(self):
    """"""
    self.rtspSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    try:
      self.rtspSocket.connect((self.serverAddr, self.serverPort))
    except:
      tkinter.messagebox.showwarning('Connection Failed', 'Connection to \'%s\' failed.' %self.serverAddr)