<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>class SockIO - TeensyMUD 3.0.0 Mud Server</title>
<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">
<script type="text/javascript">
var rdoc_rel_prefix = "./";
</script>
<script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>
<body id="top" class="class">
<nav id="metadata">
<nav id="home-section" class="section">
<h3 class="section-header">
<a href="./index.html">Home</a>
<a href="./table_of_contents.html#classes">Classes</a>
<a href="./table_of_contents.html#methods">Methods</a>
</h3>
</nav>
<nav id="search-section" class="section project-section" class="initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<h3 class="section-header">
<input type="text" name="search" placeholder="Search" id="search-field"
title="Type to search, Up and Down to navigate, Enter to load">
</h3>
</form>
<ul id="search-results" class="initially-hidden"></ul>
</nav>
<div id="file-metadata">
<nav id="file-list-section" class="section">
<h3 class="section-header">Defined In</h3>
<ul>
<li>lib/network/sockio.rb
</ul>
</nav>
</div>
<div id="class-metadata">
<nav id="parent-class-section" class="section">
<h3 class="section-header">Parent</h3>
<p class="link"><a href="Object.html">Object</a>
</nav>
<!-- Method Quickref -->
<nav id="method-list-section" class="section">
<h3 class="section-header">Methods</h3>
<ul class="link-list">
<li><a href="#method-c-new">::new</a>
<li><a href="#method-i-read">#read</a>
<li><a href="#method-i-read_flush">#read_flush</a>
<li><a href="#method-i-read_urgent">#read_urgent</a>
<li><a href="#method-i-write">#write</a>
<li><a href="#method-i-write_flush">#write_flush</a>
<li><a href="#method-i-write_urgent">#write_urgent</a>
</ul>
</nav>
</div>
<div id="project-metadata">
<nav id="fileindex-section" class="section project-section">
<h3 class="section-header">Pages</h3>
<ul>
<li class="file"><a href="./README.html">README</a>
<li class="file"><a href="./TML.html">TML</a>
</ul>
</nav>
<nav id="classindex-section" class="section project-section">
<h3 class="section-header">Class and Module Index</h3>
<ul class="link-list">
<li><a href="./Farts.html">Farts</a>
<li><a href="./Farts/AttributeSyntaxNode.html">Farts::AttributeSyntaxNode</a>
<li><a href="./Farts/CallSyntaxNode.html">Farts::CallSyntaxNode</a>
<li><a href="./Farts/CommandSyntaxNode.html">Farts::CommandSyntaxNode</a>
<li><a href="./Farts/CommentSyntaxNode.html">Farts::CommentSyntaxNode</a>
<li><a href="./Farts/EndSyntaxNode.html">Farts::EndSyntaxNode</a>
<li><a href="./Farts/IfSyntaxNode.html">Farts::IfSyntaxNode</a>
<li><a href="./Farts/Interpreter.html">Farts::Interpreter</a>
<li><a href="./Farts/Lexer.html">Farts::Lexer</a>
<li><a href="./Farts/Lib.html">Farts::Lib</a>
<li><a href="./Farts/LiteralSyntaxNode.html">Farts::LiteralSyntaxNode</a>
<li><a href="./Farts/LocalVarSyntaxNode.html">Farts::LocalVarSyntaxNode</a>
<li><a href="./Farts/Parser.html">Farts::Parser</a>
<li><a href="./Farts/ProgramSyntaxNode.html">Farts::ProgramSyntaxNode</a>
<li><a href="./Farts/SyntaxNode.html">Farts::SyntaxNode</a>
<li><a href="./SQLite.html">SQLite</a>
<li><a href="./SQLite3.html">SQLite3</a>
<li><a href="./SQLite3/Database.html">SQLite3::Database</a>
<li><a href="./SQLite/Database.html">SQLite::Database</a>
<li><a href="./TernaryTrie.html">TernaryTrie</a>
<li><a href="./TernaryTrie/TNode.html">TernaryTrie::TNode</a>
<li><a href="./ASCIICodes.html">ASCIICodes</a>
<li><a href="./Acceptor.html">Acceptor</a>
<li><a href="./Account.html">Account</a>
<li><a href="./BoolExpParser.html">BoolExpParser</a>
<li><a href="./CacheEntry.html">CacheEntry</a>
<li><a href="./CacheManager.html">CacheManager</a>
<li><a href="./CacheStats.html">CacheStats</a>
<li><a href="./Character.html">Character</a>
<li><a href="./Client.html">Client</a>
<li><a href="./Cmd.html">Cmd</a>
<li><a href="./ColorFilter.html">ColorFilter</a>
<li><a href="./Command.html">Command</a>
<li><a href="./Configuration.html">Configuration</a>
<li><a href="./Connection.html">Connection</a>
<li><a href="./Connector.html">Connector</a>
<li><a href="./ConsoleClient.html">ConsoleClient</a>
<li><a href="./CursesClient.html">CursesClient</a>
<li><a href="./DbmStore.html">DbmStore</a>
<li><a href="./DebugFilter.html">DebugFilter</a>
<li><a href="./Dumper.html">Dumper</a>
<li><a href="./Engine.html">Engine</a>
<li><a href="./Event.html">Event</a>
<li><a href="./EventManager.html">EventManager</a>
<li><a href="./Exit.html">Exit</a>
<li><a href="./Filter.html">Filter</a>
<li><a href="./GameObject.html">GameObject</a>
<li><a href="./GdbmStore.html">GdbmStore</a>
<li><a href="./LineIO.html">LineIO</a>
<li><a href="./Loader.html">Loader</a>
<li><a href="./Log.html">Log</a>
<li><a href="./Module.html">Module</a>
<li><a href="./Obj.html">Obj</a>
<li><a href="./ObjCmd.html">ObjCmd</a>
<li><a href="./Object.html">Object</a>
<li><a href="./PacketIO.html">PacketIO</a>
<li><a href="./ProtocolStack.html">ProtocolStack</a>
<li><a href="./Publisher.html">Publisher</a>
<li><a href="./Reactor.html">Reactor</a>
<li><a href="./Room.html">Room</a>
<li><a href="./Root.html">Root</a>
<li><a href="./Script.html">Script</a>
<li><a href="./SdbmStore.html">SdbmStore</a>
<li><a href="./Session.html">Session</a>
<li><a href="./SockIO.html">SockIO</a>
<li><a href="./Sqlite3Store.html">Sqlite3Store</a>
<li><a href="./SqliteStore.html">SqliteStore</a>
<li><a href="./Store.html">Store</a>
<li><a href="./String.html">String</a>
<li><a href="./TelnetCodes.html">TelnetCodes</a>
<li><a href="./TelnetFilter.html">TelnetFilter</a>
<li><a href="./TerminalFilter.html">TerminalFilter</a>
<li><a href="./Timer.html">Timer</a>
<li><a href="./Utility.html">Utility</a>
<li><a href="./VT100Codes.html">VT100Codes</a>
<li><a href="./World.html">World</a>
<li><a href="./XmlStore.html">XmlStore</a>
<li><a href="./YamlStore.html">YamlStore</a>
</ul>
</nav>
</div>
</nav>
<div id="documentation">
<h1 class="class">class SockIO</h1>
<div id="description" class="description">
<p>The <a href="SockIO.html">SockIO</a> class implements the low level
interface for TCP sockets.</p>
</div><!-- description -->
<section id="5Buntitled-5D" class="documentation-section">
<!-- Methods -->
<section id="public-class-5Buntitled-5D-method-details" class="method-section section">
<h3 class="section-header">Public Class Methods</h3>
<div id="method-c-new" class="method-detail ">
<div class="method-heading">
<span class="method-name">new</span><span
class="method-args">(sock, bufsize=8192)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Creates a new <a href="SockIO.html">SockIO</a> object</p>
<dl class="rdoc-list label-list"><dt><code>sock</code>
<dd>
<p>The socket which will be used</p>
</dd><dt><code>bufsize</code>
<dd>
<p>The size of the buffer to use (default is 8192)</p>
</dd></dl>
<div class="method-source-code" id="new-source">
<pre><span class="ruby-comment"># File lib/network/sockio.rb, line 25</span>
<span class="ruby-keyword">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-ivar">@sock</span>,<span class="ruby-ivar">@bufsize</span>=<span class="ruby-identifier">sock</span>,<span class="ruby-identifier">bufsize</span>
<span class="ruby-ivar">@inbuffer</span> = <span class="ruby-string">""</span>
<span class="ruby-ivar">@outbuffer</span> = <span class="ruby-string">""</span>
<span class="ruby-keyword">end</span></pre>
</div><!-- new-source -->
</div>
</div><!-- new-method -->
</section><!-- public-class-method-details -->
<section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
<h3 class="section-header">Public Instance Methods</h3>
<div id="method-i-read" class="method-detail ">
<div class="method-heading">
<span class="method-name">read</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>read will receive a data from the socket.</p>
<dl class="rdoc-list label-list"><dt><code>return</code>
<dd>
<p>The data read</p>
</dd><dt><code>IOError</code>
<dd>
<p>A sockets error occurred.</p>
</dd><dt><code>EOFError</code>
<dd>
<p>The connection has closed normally.</p>
</dd></dl>
<div class="method-source-code" id="read-source">
<pre><span class="ruby-comment"># File lib/network/sockio.rb, line 36</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">read</span>
<span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">recv</span>(<span class="ruby-ivar">@bufsize</span>)
<span class="ruby-keyword">end</span></pre>
</div><!-- read-source -->
</div>
</div><!-- read-method -->
<div id="method-i-read_flush" class="method-detail ">
<div class="method-heading">
<span class="method-name">read_flush</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p><a href="SockIO.html#method-i-read_flush">#read_flush</a> will kill the
input buffer</p>
<div class="method-source-code" id="read_flush-source">
<pre><span class="ruby-comment"># File lib/network/sockio.rb, line 63</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">read_flush</span>
<span class="ruby-ivar">@inbuffer</span> = <span class="ruby-string">""</span>
<span class="ruby-keyword">end</span></pre>
</div><!-- read_flush-source -->
</div>
</div><!-- read_flush-method -->
<div id="method-i-read_urgent" class="method-detail ">
<div class="method-heading">
<span class="method-name">read_urgent</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p><a href="SockIO.html#method-i-read_urgent">#read_urgent</a> will receive
urgent data from the socket.</p>
<dl class="rdoc-list label-list"><dt><code>return</code>
<dd>
<p>The data read</p>
</dd><dt><code>IOError</code>
<dd>
<p>A sockets error occurred.</p>
</dd><dt><code>EOFError</code>
<dd>
<p>The connection has closed normally.</p>
</dd></dl>
<div class="method-source-code" id="read_urgent-source">
<pre><span class="ruby-comment"># File lib/network/sockio.rb, line 72</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">read_urgent</span>
<span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">recv</span>(<span class="ruby-ivar">@bufsize</span>, <span class="ruby-constant">Socket</span><span class="ruby-operator">::</span><span class="ruby-constant">MSG_OOB</span>)
<span class="ruby-keyword">end</span></pre>
</div><!-- read_urgent-source -->
</div>
</div><!-- read_urgent-method -->
<div id="method-i-write" class="method-detail ">
<div class="method-heading">
<span class="method-name">write</span><span
class="method-args">(msg)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>write will transmit a message to the socket</p>
<dl class="rdoc-list label-list"><dt><code>msg</code>
<dd>
<p>The message string to be sent.</p>
</dd><dt><code>return</code>
<dd>
<p>false if more data to be written, true if all data written</p>
</dd><dt><code>IOError</code>
<dd>
<p>A sockets error occurred.</p>
</dd><dt><code>EOFError</code>
<dd>
<p>The connection has closed normally.</p>
</dd></dl>
<div class="method-source-code" id="write-source">
<pre><span class="ruby-comment"># File lib/network/sockio.rb, line 46</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">msg</span>)
<span class="ruby-ivar">@outbuffer</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">msg</span>
<span class="ruby-identifier">n</span> = <span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">send</span>(<span class="ruby-ivar">@outbuffer</span>, <span class="ruby-value">0</span>)
<span class="ruby-comment"># save unsent data for next call</span>
<span class="ruby-ivar">@outbuffer</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-identifier">n</span>)
<span class="ruby-ivar">@outbuffer</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span>
<span class="ruby-ivar">@outbuffer</span> = <span class="ruby-string">""</span> <span class="ruby-comment"># Does it really matter?</span>
<span class="ruby-identifier">raise</span>
<span class="ruby-keyword">end</span></pre>
</div><!-- write-source -->
</div>
</div><!-- write-method -->
<div id="method-i-write_flush" class="method-detail ">
<div class="method-heading">
<span class="method-name">write_flush</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p><a href="SockIO.html#method-i-write_flush">#write_flush</a> will kill the
output buffer</p>
<div class="method-source-code" id="write_flush-source">
<pre><span class="ruby-comment"># File lib/network/sockio.rb, line 58</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">write_flush</span>
<span class="ruby-ivar">@outbuffer</span> = <span class="ruby-string">""</span>
<span class="ruby-keyword">end</span></pre>
</div><!-- write_flush-source -->
</div>
</div><!-- write_flush-method -->
<div id="method-i-write_urgent" class="method-detail ">
<div class="method-heading">
<span class="method-name">write_urgent</span><span
class="method-args">(msg)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p><a href="SockIO.html#method-i-write_urgent">#write_urgent</a> will write
urgent data to the socket.</p>
<dl class="rdoc-list label-list"><dt><code>msg</code>
<dd>
<p>The message string to be sent.</p>
</dd><dt><code>IOError</code>
<dd>
<p>A sockets error occurred.</p>
</dd><dt><code>EOFError</code>
<dd>
<p>The connection has closed normally.</p>
</dd></dl>
<div class="method-source-code" id="write_urgent-source">
<pre><span class="ruby-comment"># File lib/network/sockio.rb, line 81</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">write_urgent</span>(<span class="ruby-identifier">msg</span>)
<span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">msg</span>, <span class="ruby-constant">Socket</span><span class="ruby-operator">::</span><span class="ruby-constant">MSG_OOB</span>)
<span class="ruby-keyword">end</span></pre>
</div><!-- write_urgent-source -->
</div>
</div><!-- write_urgent-method -->
</section><!-- public-instance-method-details -->
</section><!-- 5Buntitled-5D -->
</div><!-- documentation -->
<footer id="validator-badges">
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.1.
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
</footer>