<commit_before><?php
/**********************************************************\
|                                                          |
|                          hprose                          |
|                                                          |
| Official WebSite: http://www.hprose.com/                 |
|                   http://www.hprose.org/                 |
|                                                          |
\**********************************************************/

/**********************************************************\
 *                                                        *
 * Hprose/Socket/Server.php                               *
 *                                                        *
 * hprose socket server library for php 5.3+              *
 *                                                        *
 * LastModified: Jul 30, 2016                             *
 * Author: <NAME> <<EMAIL>>                  *
 *                                                        *
\**********************************************************/

namespace Hprose\Socket;

use Exception;

class Server extends Service {
    public $settings = array();
    public $server;
    public $uri;
    public function __construct($uri) {
        parent::__construct();
        $this->uri = $uri;
    }
    public function set($settings) {
        $this->settings = array_replace($this->settings, $settings);
    }
    private function createSocketServer() {
        $uri = $this->uri;
        $scheme = parse_url($uri, PHP_URL_SCHEME);
        if ($scheme == 'unix') {
            $uri = 'unix://' . parse_url($uri, PHP_URL_PATH);
        }
        $errno = 0;
        $errstr = '';
        $context = @stream_context_create($this->settings);
        $server = @stream_socket_server($uri, $errno, $errstr,
                STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $context);
        if ($server === false) {
            throw new Exception($errstr, $errno);
        }
        return $server;<commit_msg>Added keepAlive and noDelay support<commit_after><?php
/**********************************************************\
|                                                          |
|                          hprose                          |
|                                                          |
| Official WebSite: http://www.hprose.com/                 |
|                   http://www.hprose.org/                 |
|                                                          |
\**********************************************************/

/**********************************************************\
 *                                                        *
 * Hprose/Socket/Server.php                               *
 *                                                        *
 * hprose socket server library for php 5.3+              *
 *                                                        *
 * LastModified: Jul 30, 2016                             *
 * Author: <NAME> <<EMAIL>>                  *
 *                                                        *
\**********************************************************/

namespace Hprose\Socket;

use Exception;

class Server extends Service {
    public $settings = array();
    public $server;
    public $noDelay = true;
    public $keepAlive = true;
    public $uri;
    public function __construct($uri) {
        parent::__construct();
        $this->uri = $uri;
    }
    public function setNoDelay($value) {
        $this->noDelay = $value;
    }
    public function isNoDelay() {
        return $this->noDelay;
    }
    public function setKeepAlive($value) {
        $this->keepAlive = $value;
    }
    public function getKeepAlive() {
        return $this->keepAlive;
    }
    public function set($settings) {
        $this->settings = array_replace($this->settings, $settings);
    }
    private function createSocketServer() {
        $uri = $this->uri;
        $scheme = parse_url($uri, PHP_URL_SCHEME);
        if ($scheme == 'unix') {
            $uri = 'unix://' . parse_url($uri, PHP_URL_PATH);
        }
        $errno = 0;
        $errstr = '';
        $context = @stream_context_create($this->settings);
        $server = @stream_socket_server($uri, $errno, $errstr,
                STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $context);
        $socket = socket_import_stream($server);
        socket_set_option($socket, SOL_SOCKET, SO_KEEPALIVE, (int)$this->keepAlive);
        if ($scheme !== 'unix') {
            socket_set_option($socket, SOL_TCP, TCP_NODELAY, (int)$this->noDelay);
        }
        if ($server === false) {
            throw new Exception($errstr, $errno);
        }
        return $server;
{'fraction_non_alphanumeric': 0.1996630160067397, 'fraction_numerical': 0.0037910699241786015, 'mean_word_length': 1.2897782063645131, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5272511', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1064, 'n_words': 210}