any open input/output stream accessing this port becomes unusable
513088
@Override
	public final void close()
	{
		try {
			if (fd != INVALID_HANDLE)
				close0();
		}
		catch (final IOException e) {
			logger.error("closing serial port", e);
		}
		fd = INVALID_HANDLE;
	}
326473
def _fix_mutect_output(orig_file, config, out_file, is_paired):
    
    out_file_noc = out_file.replace(".vcf.gz", ".vcf")
    none_index = -1
    with file_transaction(config, out_file_noc) as tx_out_file:
        with open_gzipsafe(orig_file) as in_handle:
            with open(tx_out_file, 'w') as out_handle:
                for line in in_handle:
                    if not is_paired and line.startswith("#CHROM"):
                        parts = line.rstrip().split("\t")
                        none_index = parts.index("none")
                        del parts[none_index]
                        line = "\t".join(parts) + "\n"
                    elif line.startswith("##FORMAT=<ID=FA"):
                        line = line.replace("=FA", "=FREQ")
                    elif not line.startswith("#"):
                        if none_index > 0:
                            parts = line.rstrip().split("\t")
                            del parts[none_index]
                            line = "\t".join(parts) + "\n"
                        line = line.replace("FA", "FREQ")
                    out_handle.write(line)
    return bgzip_and_index(out_file_noc, config)
1128068
def get_unused_port(port=None):
    """"""
    if port is None or port < 1024 or port > 65535:
        port = random.randint(1024, 65535)
    assert(1024 <= port <= 65535)
    while True:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        try:
            s.bind(('', port))  # Try to open port
        except socket.error as e:
            if e.errno in (98, 10048):  # 98, 10048 means address already bound
                return get_unused_port(None)
            raise e
        s.close()
        return port
708287
def open(self, input_streams=['stdin'], output_streams=['stderr', 'stdout']):
        
        shell = dict()
        shell['rsp:InputStreams'] = " ".join(input_streams)
        shell['rsp:OutputStreams'] = " ".join(output_streams)
        shell['rsp:IdleTimeout'] = str(self.idle_timeout)

        if self.working_directory is not None:
            shell['rsp:WorkingDirectory'] = str(self.working_directory)

        if self.environment is not None:
            variables = []
            for key, value in self.environment.items():
                variables.append({'#text': str(value), '@Name': key})
            shell['rsp:Environment'] = {'Variable': variables}

        response = self.session.create(self.resource, {'rsp:Shell': shell})
        self.__shell_id = response['rsp:Shell']['rsp:ShellId']
292129
public void handleInputStream(final InputStream is) throws IOException
        {
        LOG.trace("Handling input stream.");
        final OutputStream os = new FileOutputStream(this.m_file);
        try
            {
            final long bytesWritten = org.littleshoot.util.IoUtils.copy(is, os, 
                this.m_writeListener);
            LOG.trace("Wrote "+bytesWritten+" to file: "+this.m_file);
            }
        finally
            {
            IOUtils.closeQuietly(is);
            IOUtils.closeQuietly(os);
            }
        }
233404
def open(self):
        """"""
        if not self.closed:
            return
        self.outs = self.ins = open(
            "/dev/net/tun" if LINUX else ("/dev/%s" % self.iface), "r+b",
            buffering=0
        )
        if LINUX:
            from fcntl import ioctl
            # TUNSETIFF = 0x400454ca
            # IFF_TUN = 0x0001
            # IFF_TAP = 0x0002
            # IFF_NO_PI = 0x1000
            ioctl(self.ins, 0x400454ca, struct.pack(
                "16sH", bytes_encode(self.iface),
                0x0001 if self.mode_tun else 0x1002,
            ))
        self.closed = False
503798
public function open()
  {
    if ($this->isOpen()) {
      throw new TTransportException('Socket already connected', TTransportException::ALREADY_OPEN);
    }

    if (empty($this->host_)) {
      throw new TTransportException('Cannot open null host', TTransportException::NOT_OPEN);
    }

    if ($this->port_ <= 0) {
      throw new TTransportException('Cannot open without port', TTransportException::NOT_OPEN);
    }

    if ($this->persist_) {
      $this->handle_ = @pfsockopen($this->host_,
                                   $this->port_,
                                   $errno,
                                   $errstr,
                                   $this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000));
    } else {
      $this->handle_ = @fsockopen($this->host_,
                                  $this->port_,
                                  $errno,
                                  $errstr,
                                  $this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000));
    }

    // Connect failed?
    if ($this->handle_ === FALSE) {
      $error = 'TSocket: Could not connect to '.$this->host_.':'.$this->port_.' ('.$errstr.' ['.$errno.'])';
      if ($this->debug_) {
        call_user_func($this->debugHandler_, $error);
      }
      throw new TException($error);
    }
  }
351422
static OutputStream connectToOneServer(String server, int port) throws IOException {
        try {
            Socket pushSocket = new Socket(server, port);
            OutputStream out = pushSocket.getOutputStream();
            m_logger.info("Connected to export endpoint node at: " + server + ":" + port);
            return out;
        } catch (UnknownHostException e) {
            m_logger.rateLimitedLog(120, Level.ERROR, e, "Don't know about host: " + server);
            throw e;
        } catch (IOException e) {
            m_logger.rateLimitedLog(120, Level.ERROR, e, "Couldn't get I/O for the connection to: " + server);
            throw e;
        }
    }
459295
def pick_unused_port():
  
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.bind(('localhost', 0))
  addr, port = s.getsockname()
  s.close()
  return port
727893
def open_ports(start, end, protocol="TCP"):
    """"""
    _args = ['open-port']
    _args.append('{}-{}/{}'.format(start, end, protocol))
    subprocess.check_call(_args)
1355007
function (application) {
    /*  determine connector filename  */
    var id = os.platform() + "-" + application;
    var cn = connectors[id];
    if (typeof cn === "undefined")
        throw new Error("unsupported platform/application combination: " + id);
    var filename = path.join(__dirname, cn);

    /*  spawn the connector as a child process  */
    this.c = spawn(filename, [], {
        stdio: [ "pipe", "pipe", process.stderr ],
        env: { "CONNECTOR": "FIXME" }
    });

    /*  set the stdin/stdout pipes to UTF-8 encoding mode  */
    this.c.stdin.setEncoding("utf8");
    this.c.stdout.setEncoding("utf8");

    /*  create line-based duplex stream out of stdin/stdout piples  */
    this.io = es.duplex(
        this.c.stdin,
        this.c.stdout.pipe(es.split(/\r?\n/))
    );

    /*  connect to the stream for capturing responses  */
    this.responses = [];
    this.io.pipe(es.through(function onData (data) {
        if (typeof data === "undefined" || data === "")
            return;
        var response = this.responses.shift();
        if (typeof response === "function")
            response(data);
    }.bind(this), function onEnd () {
        /*  currently nothing to do?!  */
    }));
}
595380
public void setProcessInputStream(OutputStream os) {
    if (input != null) {
      if (input == System.in) {
        inputThread = createSystemInPump(input, os);
      }
      else {
        inputThread = createPump(input, os, true, true);
      }
    }
    else {
      try {
        os.close();
      }
      catch (IOException e) {
        log.info("Got exception while closing output stream", e);
      }
    }
  }
28901
def connect(self, addr):
        '''
        
        '''
        if addr.find(':') == -1:
            addr += ':5555'
        output = self.run_cmd('connect', addr)
        return 'unable to connect' not in output
1120947
protected void handleOutput(InputStream stdout) throws IOException {
        byte[] buffer = new byte[4 * 1024];
        int    b;
        while ((b = stdout.read(buffer)) > 0) {
            out.write(buffer, 0, b);
        }
    }
741974
def allocate_port():
    
    sock = socket.socket()
    try:
        sock.bind(("localhost", 0))
        return get_port(sock)
    finally:
        sock.close()
45124
private void open(String host, int port, SocketFactory fact, int conTimeout) throws ApiConnectionException {
        try {
            InetAddress ia = InetAddress.getByName(host.trim());
            sock = fact.createSocket();
            sock.connect(new InetSocketAddress(ia, port), conTimeout);
            in = new DataInputStream(sock.getInputStream());
            out = new DataOutputStream(sock.getOutputStream());
            connected = true;
            reader = new Reader();
            reader.setDaemon(true);
            reader.start();
            processor = new Processor();
            processor.setDaemon(true);
            processor.start();
        } catch (UnknownHostException ex) {
            connected = false;
            throw new ApiConnectionException(String.format("Unknown host '%s'", host), ex);
        } catch (IOException ex) {
            connected = false;
            throw new ApiConnectionException(String.format("Error connecting to %s:%d : %s", host, port, ex.getMessage()), ex);
        }
    }
1066838
public InputStream openInputStream() throws FetchException {
        try {
            return getInternalBlobForFetch().getBinaryStream();
        } catch (SQLException e) {
            throw mRepo.toFetchException(e);
        }
    }