<commit_before><?php
//
// +----------------------------------------------------------------------+
// | PHP Version 4                                                        |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group                                |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available at through the world-wide-web at                           |
// | http://www.php.net/license/2_02.txt.                                 |
// | If you did not receive a copy of the PHP license and are unable to   |
// | obtain it through the world-wide-web, please send a note to          |
// | <EMAIL> so we can mail you a copy immediately.               |
// +----------------------------------------------------------------------+
// | Authors: <NAME> <<EMAIL>>                                   |
// |          <NAME> <<EMAIL>>                           |
// +----------------------------------------------------------------------+
//
// $Id: Socket.php,v 1.1 2003-07-25 08:24:53 redflo Exp $
//

require_once 'PEAR.php';

/**
 * Generalized Socket class. More docs to be written.
 *
 * @version 1.0
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
class Net_Socket extends PEAR {
    
    // {{{ properties
    
    /** Socket file pointer. */
    var $fp = null;
    
    /** Whether the socket is blocking. */
    var $blocking = true;
    
    /** Whether the socket is persistent. */
    var $persistent = false;
    
    /** The IP address to connect to. */
    var $addr = '';
    
    /** The port number to connect to. */
    var $port = 0;
    
    /** Number of seconds to wait on socket connections before
        assuming there's no more data. */
    var $timeout = false;
    
    /** Number of bytes to read at a time in readLine() and
        readAll(). */
    var $lineLength = 2048;
    // }}}
    
    // {{{ constructor
    /**
     * Constructs a new Net_Socket object.
     *
     * @access public
     */
    function Net_Socket() {
        $this->PEAR();
    }
    // }}}
    
    // {{{ connect()
    /**
     * Connect to the specified port. If called when the socket is
     * already connected, it disconnects and connects again.
     *
     * @param $addr string IP address or host name
     * @param $port int TCP port number
     * @param $persistent bool (optional) whether the connection is
     *        persistent (kept open between requests by the web server)
     * @param $timeout int (optional) how long to wait for data
     * @access public
     * @return mixed true on success or error object
     */
    function connect($addr, $port, $persistent = null, $timeout = null) {
        if (is_resource($this->fp)) {
            @fclose($this->fp);
            $this->fp = null;
        }
        
        if (strspn($addr, '.0123456789') == strlen($addr)) {
            $this->addr = $addr;
        } else {
            $this->addr = gethostbyname($addr);
        }
        $this->port = $port % 65536;
        if ($persistent !== null) {
            $this->persistent = $persistent;
        }
        if ($timeout !== null) {
            $this->timeout = $timeout;
        }
        $openfunc = $this->persistent ? 'pfsockopen' : 'fsockopen';
        $errno = 0;
        $errstr = '';
        if ($this->timeout) {
            $fp = $openfunc($this->addr, $this->port, $errno, $errstr, $this->timeout);
        } else {
            $fp = $openfunc($this->addr, $this->port, $errno, $errstr);
        }<commit_msg>inhibited the display for fsockopen error (on tw.o) by a raw @. optipmally that fsockopen shouldn't occur more than once, need more work on it...<commit_after><?php
//
// +----------------------------------------------------------------------+
// | PHP Version 4                                                        |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group                                |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available at through the world-wide-web at                           |
// | http://www.php.net/license/2_02.txt.                                 |
// | If you did not receive a copy of the PHP license and are unable to   |
// | obtain it through the world-wide-web, please send a note to          |
// | license@php.net so we can mail you a copy immediately.               |
// +----------------------------------------------------------------------+
// | Authors: <NAME> <<EMAIL>>                                   |
// |          <NAME> <<EMAIL>>                           |
// +----------------------------------------------------------------------+
//
// $Id: Socket.php,v 1.2 2003-10-12 16:03:03 mose Exp $
//

require_once 'PEAR.php';

/**
 * Generalized Socket class. More docs to be written.
 *
 * @version 1.0
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
class Net_Socket extends PEAR {
    
    // {{{ properties
    
    /** Socket file pointer. */
    var $fp = null;
    
    /** Whether the socket is blocking. */
    var $blocking = true;
    
    /** Whether the socket is persistent. */
    var $persistent = false;
    
    /** The IP address to connect to. */
    var $addr = '';
    
    /** The port number to connect to. */
    var $port = 0;
    
    /** Number of seconds to wait on socket connections before
        assuming there's no more data. */
    var $timeout = false;
    
    /** Number of bytes to read at a time in readLine() and
        readAll(). */
    var $lineLength = 2048;
    // }}}
    
    // {{{ constructor
    /**
     * Constructs a new Net_Socket object.
     *
     * @access public
     */
    function Net_Socket() {
        $this->PEAR();
    }
    // }}}
    
    // {{{ connect()
    /**
     * Connect to the specified port. If called when the socket is
     * already connected, it disconnects and connects again.
     *
     * @param $addr string IP address or host name
     * @param $port int TCP port number
     * @param $persistent bool (optional) whether the connection is
     *        persistent (kept open between requests by the web server)
     * @param $timeout int (optional) how long to wait for data
     * @access public
     * @return mixed true on success or error object
     */
    function connect($addr, $port, $persistent = null, $timeout = null) {
        if (is_resource($this->fp)) {
            @fclose($this->fp);
            $this->fp = null;
        }
        
        if (strspn($addr, '.0123456789') == strlen($addr)) {
            $this->addr = $addr;
        } else {
            $this->addr = gethostbyname($addr);
        }
        $this->port = $port % 65536;
        if ($persistent !== null) {
            $this->persistent = $persistent;
        }
        if ($timeout !== null) {
            $this->timeout = $timeout;
        }
        $openfunc = $this->persistent ? 'pfsockopen' : 'fsockopen';
        $errno = 0;
        $errstr = '';
        if ($this->timeout) {
            $fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $this->timeout);
        } else {
            $fp = @$openfunc($this->addr, $this->port, $errno, $errstr);
        }
{'fraction_non_alphanumeric': 0.21796218487394958, 'fraction_numerical': 0.013918067226890757, 'mean_word_length': 1.256888888888889, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6924189', 'n_tokens_mistral': 2103, 'n_tokens_neox': 2014, 'n_words': 657}