<commit_before><?php

namespace BaseX;

use BaseX\Query;

/** 
 * @file PHP client for BaseX.
 * Works with BaseX 7.0 and later
 *
 * Documentation: http://docs.basex.org/wiki/Clients
 * 
 * (C) BaseX Team 2005-12, BSD License
 */

/**
 * Session communicating with BaseX Server.
 *
 * Socket-based implementation.
 *
 */ 
class Session 
{
  /**
   *
   * @var resource
   */
  protected $socket;
  
  /**
   * @var string
   */
   protected $info = null;
   
  /**
   * @var string
   */
   protected $buffer = null;
   
   /**
    *
    * @var int
    */
   protected $bpos = null;
   
   /**
    *
    * @var int
    */
   protected $bsize = null;

   /**
    * Creates a new Session
    * 
    * @param string $host Server hostname
    * @param string $port Port to use
    * @param string $user Username
    * @param type $pass   Password
    * @throws \Exception 
    */
  function __construct($host, $port, $user, $pass) {
    // create server connection
    $this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    
    if(!socket_connect($this->socket, $host, $pass)) 
    {
      throw new \Exception("Can't communicate with server.");
    }

    // receive timestamp
    $ts = $this->readString();

    // send username and hashed password/timestamp
    $md5 = hash("md5", hash("md5", $pass).$ts);<commit_msg>- Fix bug in socket connection<commit_after><?php

namespace BaseX;

use BaseX\Query;

/** 
 * @file PHP client for BaseX.
 * Works with BaseX 7.0 and later
 *
 * Documentation: http://docs.basex.org/wiki/Clients
 * 
 * (C) BaseX Team 2005-12, BSD License
 */

/**
 * Session communicating with BaseX Server.
 *
 * Socket-based implementation.
 *
 */ 
class Session 
{
  /**
   *
   * @var resource
   */
  protected $socket;
  
  /**
   * @var string
   */
   protected $info = null;
   
  /**
   * @var string
   */
   protected $buffer = null;
   
   /**
    *
    * @var int
    */
   protected $bpos = null;
   
   /**
    *
    * @var int
    */
   protected $bsize = null;

   /**
    * Creates a new Session
    * 
    * @param string $host Server hostname
    * @param string $port Port to use
    * @param string $user Username
    * @param type $pass   Password
    * @throws \Exception 
    */
  function __construct($host, $port, $user, $pass) {
    // create server connection
    $this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    
    if(!socket_connect($this->socket, $host, $port)) 
    {
      throw new \Exception("Can't communicate with server.");
    }

    // receive timestamp
    $ts = $this->readString();

    // send username and hashed password/timestamp
    $md5 = hash("md5", hash("md5", $pass).$ts);
{'fraction_non_alphanumeric': 0.1446728971962617, 'fraction_numerical': 0.00822429906542056, 'mean_word_length': 2.2279855247285885, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3703893', 'n_tokens_mistral': 916, 'n_tokens_neox': 878, 'n_words': 236}