tmud-2.10.1/benchmark/
tmud-2.10.1/cmd/
tmud-2.10.1/cmd/objects/
tmud-2.10.1/cmd/tiny/
tmud-2.10.1/doc/classes/SQLite/
tmud-2.10.1/doc/classes/SQLite3/
tmud-2.10.1/doc/classes/TernaryTrie/
tmud-2.10.1/doc/files/cmd/objects/
tmud-2.10.1/doc/files/cmd/tiny/
tmud-2.10.1/doc/files/lib/
tmud-2.10.1/doc/files/lib/engine/
tmud-2.10.1/doc/files/lib/farts/
tmud-2.10.1/farts/
tmud-2.10.1/lib/
tmud-2.10.1/lib/core/
tmud-2.10.1/lib/engine/
tmud-2.10.1/lib/farts/
tmud-2.10.1/logs/
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: LineIO</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">LineIO</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/lib/network/lineio_rb.html">
                lib/network/lineio.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="SockIO.html">
                SockIO
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">
    <div id="diagram">
      <map id="map" name="map">
  <area shape="rect" coords="5,101,77,149"      href="LineIO.html" alt="LineIO
" />
  <area shape="rect" coords="5,5,77,53"      href="SockIO.html" alt="SockIO
" />
</map>
<img src="../dot/f_27.png" usemap="#map" border="0" alt="dot/f_27.png">
    </div>

    <div id="description">
      <p>
The <a href="LineIO.html">LineIO</a> class implements a line-orient
interface for TCP sockets. It&#8216;s a specialization of sockio. This
class is intended for line-oriented protocols.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000200">new</a>&nbsp;&nbsp;
      <a href="#M000201">read</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000200" class="method-detail">
        <a name="M000200"></a>

        <div class="method-heading">
          <a href="#M000200" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(sock, bufsize=8192)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Creates a <a href="LineIO.html#M000200">new</a> <a
href="LineIO.html">LineIO</a> object
</p>
<dl>
<dt><tt>sock</tt></dt><dd>The socket which will be used

</dd>
<dt><tt>bufsize</tt></dt><dd>The size of the buffer to use (default is 8192)

</dd>
</dl>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000200-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000200-source">
<pre>
<span class="ruby-comment cmt"># File lib/network/lineio.rb, line 27</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">sock</span>, <span class="ruby-identifier">bufsize</span>=<span class="ruby-value">8192</span>)
    <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">sock</span>,<span class="ruby-identifier">bufsize</span>)
  <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000201" class="method-detail">
        <a name="M000201"></a>

        <div class="method-heading">
          <a href="#M000201" class="method-signature">
          <span class="method-name">read</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
<a href="LineIO.html#M000201">read</a> will receive a set of lines from the
socket. A line may be terminated by CRLF, CRNUL, LFCR, CR, or LF. Not yet
terminated lines are left in the @inbuffer.
</p>
<dl>
<dt><tt>return</tt></dt><dd>One or more complete lines or nil.

</dd>
<dt><tt>IOError</tt></dt><dd>A sockets error occurred.

</dd>
<dt><tt>EOFError</tt></dt><dd>The connection has closed normally.

</dd>
</dl>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000201-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000201-source">
<pre>
<span class="ruby-comment cmt"># File lib/network/lineio.rb, line 38</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read</span>
    <span class="ruby-ivar">@inbuffer</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">recv</span>(<span class="ruby-ivar">@bufsize</span>)
    <span class="ruby-ivar">@inbuffer</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/\r\n|\r\x00|\n\r|\r|\n/</span>,<span class="ruby-value str">&quot;\n&quot;</span>)
    <span class="ruby-identifier">pos</span> = <span class="ruby-ivar">@inbuffer</span>.<span class="ruby-identifier">rindex</span>(<span class="ruby-value str">&quot;\n&quot;</span>)
    <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pos</span>
      <span class="ruby-identifier">ln</span> = <span class="ruby-ivar">@inbuffer</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-identifier">pos</span>)
      <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">ln</span>
    <span class="ruby-keyword kw">end</span>
    <span class="ruby-keyword kw">nil</span>
  <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>