PacketIO.html
tmud-2.10.0/doc/classes/PacketIO.html · 5.5 KB
From the archive tmud-2.10.0.tar.gz
Download the archive « Back to the archive contents
<?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: PacketIO</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">PacketIO</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../files/lib/network/packetio_rb.html">
lib/network/packetio.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="35,113,107,161" href="PacketIO.html" alt="PacketIO
">
<area shape="RECT" coords="35,17,107,65" href="SockIO.html" alt="SockIO
">
</map>
<img src="../dot/f_28.png" usemap="#map" border=0 alt="TopLevel">
</div>
<div id="description">
<p>
The <a href="PacketIO.html">PacketIO</a> class implements a mechanism to
send and recv packets delimited by a length prefix which is assumed to be a
4 bytes integer in network byte order.
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000228">new</a>
<a href="#M000229">read</a>
<a href="#M000230">write</a>
</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-M000228" class="method-detail">
<a name="M000228"></a>
<div class="method-heading">
<a href="PacketIO.src/M000228.html" target="Code" class="method-signature"
onclick="popupCode('PacketIO.src/M000228.html');return false;">
<span class="method-name">new</span><span class="method-args">(sock, bufsize=16380)</span>
</a>
</div>
<div class="method-description">
<p>
Creates a new PackIO 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 16K)
</dd>
</dl>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000229" class="method-detail">
<a name="M000229"></a>
<div class="method-heading">
<a href="PacketIO.src/M000229.html" target="Code" class="method-signature"
onclick="popupCode('PacketIO.src/M000229.html');return false;">
<span class="method-name">read</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p>
read will receive a data from the socket.
</p>
<dl>
<dt><tt>return</tt></dt><dd>The data read
</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>
</div>
</div>
<div id="method-M000230" class="method-detail">
<a name="M000230"></a>
<div class="method-heading">
<a href="PacketIO.src/M000230.html" target="Code" class="method-signature"
onclick="popupCode('PacketIO.src/M000230.html');return false;">
<span class="method-name">write</span><span class="method-args">(msg)</span>
</a>
</div>
<div class="method-description">
<p>
write will transmit a packet to the socket, we calculated the size here
</p>
<dl>
<dt><tt>msg</tt></dt><dd>The message string to be sent.
</dd>
<dt><tt>return</tt></dt><dd>false if more data to be written, true if all data written
</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>
</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>