Open a stream to the target server for the load balancer.

@return the socket's read/write pair.
342130
@Override
  public ClientSocket open()
  {
    State state = _state;
    
    if (! state.isInit())
      return null;

    ClientSocket stream = openRecycle();

    if (stream != null)
      return stream;

    return connect();
  }
379155
public StreamImpl openReadImpl() throws IOException
  {
    if (_isWindows && isAux())
      throw new FileNotFoundException(_file.toString());

    /* XXX: only for Solaris (?)
    if (isDirectory())
      throw new IOException("is directory");
    */

    return new FileReadStream(new FileInputStream(getFile()), this);
  }
490521
public int start() throws IOException {
		synchronized (this.monitor) {
			Assert.state(!isStarted(), "Server already started");
			logger.debug("Starting live reload server on port " + this.port);
			this.serverSocket = new ServerSocket(this.port);
			int localPort = this.serverSocket.getLocalPort();
			this.listenThread = this.threadFactory.newThread(this::acceptConnections);
			this.listenThread.setDaemon(true);
			this.listenThread.setName("Live Reload Server");
			this.listenThread.start();
			return localPort;
		}
	}
529421
public ClientSocket openIfHeartbeatActive()
  {
    if (_state.isClosed()) {
      return null;
    }
    
    if (! _isHeartbeatActive && _isHeartbeatServer) {
      return null;
    }

    ClientSocket stream = openRecycle();

    if (stream != null)
      return stream;

    return connect();
  }
260412
public static <OUT> Iterator<OUT> collect(DataStream<OUT> stream) throws IOException {

		TypeSerializer<OUT> serializer = stream.getType().createSerializer(
				stream.getExecutionEnvironment().getConfig());

		SocketStreamIterator<OUT> iter = new SocketStreamIterator<OUT>(serializer);

		//Find out what IP of us should be given to CollectSink, that it will be able to connect to
		StreamExecutionEnvironment env = stream.getExecutionEnvironment();
		InetAddress clientAddress;

		if (env instanceof RemoteStreamEnvironment) {
			String host = ((RemoteStreamEnvironment) env).getHost();
			int port = ((RemoteStreamEnvironment) env).getPort();
			try {
				clientAddress = ConnectionUtils.findConnectingAddress(new InetSocketAddress(host, port), 2000, 400);
			}
			catch (Exception e) {
				throw new IOException("Could not determine an suitable network address to " +
						"receive back data from the streaming program.", e);
			}
		} else if (env instanceof LocalStreamEnvironment) {
			clientAddress = InetAddress.getLoopbackAddress();
		} else {
			try {
				clientAddress = InetAddress.getLocalHost();
			} catch (UnknownHostException e) {
				throw new IOException("Could not determine this machines own local address to " +
						"receive back data from the streaming program.", e);
			}
		}

		DataStreamSink<OUT> sink = stream.addSink(new CollectSink<OUT>(clientAddress, iter.getPort(), serializer));
		sink.setParallelism(1); // It would not work if multiple instances would connect to the same port

		(new CallExecute(env, iter)).start();

		return iter;
	}
1201630
def open(self):
        
        self._wr_lock.acquire()
        self._rd_lock.acquire()
        try:
            self.data_in = EMPTY_BUFFER
            self._running.set()
            sock_addresses = self._get_socket_addresses()
            self.socket = self._find_address_and_connect(sock_addresses)
            self.poller = Poller(self.socket.fileno(), self._exceptions,
                                 timeout=self._parameters['timeout'])
            self._inbound_thread = self._create_inbound_thread()
        finally:
            self._wr_lock.release()
            self._rd_lock.release()
129020
DFSInputStream open(String src, int buffersize, boolean verifyChecksum,
      FileSystem.Statistics stats, boolean clearOsBuffer,
      ReadOptions options
      ) throws IOException {
    checkOpen();

    incFileReadToStats();
    // Get block info from namenode
    DFSInputStream stream = new DFSInputStream(this, src, buffersize,
        verifyChecksum, clearOsBuffer, options);
    if (blockLocationRenewal != null) {
      blockLocationRenewal.add(stream);
    }
    return stream;
  }
537643
public InputStream openInputStream()
    throws IOException
  {
    close();

    TempBuffer head = _head;
    _head = null;
    _tail = null;

    return new TempInputStream(head);
  }
1017394
@Override
    public InputStream getInputStream() throws IOException {
	if (barr == null) {
	    barr = IOUtil.toBytes(url.openStream());
	}
	return new ByteArrayInputStream(barr);
    }
562431
protected synchronized InputStream getInputStream() throws IOException {
        if (isClosedOrPending()) {
            throw new IOException("Socket Closed");
        }
        if (shut_rd) {
            throw new IOException("Socket input is shutdown");
        }
        if (socketInputStream == null) {
            socketInputStream = new SocketInputStream(this);
        }
        return socketInputStream;
    }
1032386
public ReadStream openRead()
    throws IOException
  {
    if (_isDone)
      return null;
    else if (_readStream == null)
      _readStream = new ReadStream(this);
    else if (!_isPartDone) {
      int len;
      while ((len = read(_dummyBuffer, 0, _dummyBuffer.length)) >= 0) {
      }

      if (_isDone)
        return null;
    }

    _readStream.init(this);

    _isPartDone = false;

    if (scanHeaders()) {
      String contentType = (String) getAttribute("content-type");

      String charset = getAttributePart(contentType, "charset");

      // FIXME: 2016-05-14 
/*
      if (charset != null)
        _readStream.setEncoding(charset);
      else if (_defaultEncoding != null)
        _readStream.setEncoding(_defaultEncoding);
*/

      return _readStream;
    }
    else {
      _isDone = true;
      _readStream.close();
      return null;
    }
  }
334364
SocketChannel createSock() throws IOException {
        SocketChannel sock;
        sock = SocketChannel.open();
        sock.configureBlocking(false);
        sock.socket().setSoLinger(false, -1);
        sock.socket().setTcpNoDelay(true);
        return sock;
    }
543317
@Override
    public InputStream openInputStream() throws IOException {
        if (outputStream != null) {
            return new ByteArrayInputStream(outputStream.toByteArray());
        } else {
            return new ByteArrayInputStream(new byte[0]);
        }
    }
1070504
public StreamImpl openReadImpl() throws IOException
  {
    HttpStreamWrapper stream = HttpStream.openRead(this);

    stream.setSSL(true);
    
    return stream;
  }
409890
public Reader openReader() throws FetchException {
        try {
            return getInternalClobForFetch().getCharacterStream();
        } catch (SQLException e) {
            throw mRepo.toFetchException(e);
        }
    }
1264155
public Socket connect() throws IOException {
        final Socket socket = this.createSocket();
        final InetAddress destinationAddress = this.getResolvedDestinationAddress();
        final int destinationPort = this.getDestinationPort();
        final SocketAddress destination = new InetSocketAddress(destinationAddress, destinationPort);
        socket.connect(destination);

        return socket;
    }
765370
public InputStream openStream() {
        try {
            URLConnection urlConnection = logStreamURL.openConnection();
            if (urlConnection instanceof HttpsURLConnection) {
                HttpsURLConnection https = (HttpsURLConnection) urlConnection;
                https.setSSLSocketFactory(Heroku.sslContext(false).getSocketFactory());
                https.setHostnameVerifier(Heroku.hostnameVerifier(false));
            }
            urlConnection.connect();
            return urlConnection.getInputStream();

        } catch (IOException e) {
            throw new HerokuAPIException("IOException while opening log stream", e);
        }
    }