|
|
Note: generate this file with `makeinfo --html --no-split doc/guile-torrent.texi`.
|
|
|
|
|
|
<a name="SEC_Contents"></a>
|
|
|
<h2 class="contents-heading">Table of Contents</h2>
|
|
|
|
|
|
<div class="contents">
|
... | ... | @@ -9,6 +10,7 @@ Note: generate this file with `makeinfo --html --no-split doc/guile-torrent.texi |
|
|
<li><a name="toc-Managing-_002etorrent-files-1" href="#Managing-_002etorrent-files">2 Managing .torrent files</a></li>
|
|
|
<li><a name="toc-Connecting-to-Trackers-1" href="#Connecting-to-Trackers">3 Connecting to Trackers</a></li>
|
|
|
<li><a name="toc-Sending-and-Receiving-Messages-1" href="#Sending-and-Receiving-Messages">4 Sending and Receiving Messages</a></li>
|
|
|
<li><a name="toc-Reading-and-Writing-Downloaded-Files-1" href="#Reading-and-Writing-Downloaded-Files">5 Reading and Writing Downloaded Files</a></li>
|
|
|
</ul>
|
|
|
</div>
|
|
|
|
... | ... | @@ -33,6 +35,8 @@ implementation of the bittorrent protocol. |
|
|
</td></tr>
|
|
|
<tr><td align="left" valign="top">• <a href="#Sending-and-Receiving-Messages" accesskey="4">Sending and Receiving Messages</a>:</td><td> </td><td align="left" valign="top">
|
|
|
</td></tr>
|
|
|
<tr><td align="left" valign="top">• <a href="#Reading-and-Writing-Downloaded-Files" accesskey="5">Reading and Writing Downloaded Files</a>:</td><td> </td><td align="left" valign="top">
|
|
|
</td></tr>
|
|
|
</table>
|
|
|
|
|
|
<hr>
|
... | ... | @@ -352,11 +356,22 @@ error. |
|
|
object. It returns this new <code>tracker</code> object.
|
|
|
</p></dd></dl>
|
|
|
|
|
|
<dl>
|
|
|
<dt><a name="index-tracker_002dfiber"></a>Scheme Procedure: <strong>tracker-fiber</strong> <em><var>tracker</var> <var>peerid</var> <var>port</var> <var>infohash</var> <var>ending-channel</var> <var>peers-channel</var></em></dt>
|
|
|
<dd><p>This procedures runs a fiber that connects to the given <var>tracker</var>.
|
|
|
<var>peerid</var> and <var>port</var> are our peer ID and port on which we are listening
|
|
|
for connections. <var>ending-channel</var> is a channel on which the fiber listens
|
|
|
from the <code>'stop</code> message. <var>peers-channel</var> is a channel on which the
|
|
|
fiber will put messages about newly found peers. Messages from this fiber
|
|
|
are always of this form:
|
|
|
<code>`(("type" 'new-peers) ("new-peers" <tracker-response-peers>))</code>.
|
|
|
</p></dd></dl>
|
|
|
|
|
|
<hr>
|
|
|
<a name="Sending-and-Receiving-Messages"></a>
|
|
|
<div class="header">
|
|
|
<p>
|
|
|
Previous: <a href="#Connecting-to-Trackers" accesskey="p" rel="prev">Connecting to Trackers</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
|
|
|
Next: <a href="#Reading-and-Writing-Downloaded-Files" accesskey="n" rel="next">Reading and Writing Downloaded Files</a>, Previous: <a href="#Connecting-to-Trackers" accesskey="p" rel="prev">Connecting to Trackers</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
|
|
|
</div>
|
|
|
<a name="Sending-and-Receiving-Messages-1"></a>
|
|
|
<h2 class="chapter">4 Sending and Receiving Messages</h2>
|
... | ... | @@ -551,3 +566,102 @@ whether that peer has piece number <var>piece</var>. |
|
|
<dd><p>Update <var>bitfield</var> such that it now has the bit corresponding to piece
|
|
|
number <var>piece</var> set.
|
|
|
</p></dd></dl>
|
|
|
|
|
|
<p>Additionnaly, this module defines higher-level functions and data types:
|
|
|
</p>
|
|
|
<dl>
|
|
|
<dt><a name="index-potential_002dpeer"></a>Data Type: <strong>potential-peer</strong></dt>
|
|
|
<dd><p>This data type represents coordinates to a peer we aren’t currently connected
|
|
|
to. This is typically used to record peer lists received from trackers or
|
|
|
other protocols.
|
|
|
</p>
|
|
|
<dl compact="compact">
|
|
|
<dt>host</dt>
|
|
|
<dd><p>The host of the peer.
|
|
|
</p>
|
|
|
</dd>
|
|
|
<dt>port</dt>
|
|
|
<dd><p>The port the peer listens on.
|
|
|
</p>
|
|
|
</dd>
|
|
|
<dt>freshness</dt>
|
|
|
<dd><p>Determines whether we learned about that peer a short or a long time ago.
|
|
|
</p>
|
|
|
</dd>
|
|
|
</dl>
|
|
|
</dd></dl>
|
|
|
|
|
|
<dl>
|
|
|
<dt><a name="index-merge_002dpotential_002dpeers"></a>Scheme Procedure: <strong>merge-potential-peers</strong> <em><var>old-peers</var> <var>new-peers</var></em></dt>
|
|
|
<dd><p>Returns a new list of potential peers that adds peers from <var>new-peers</var> to
|
|
|
<var>old-peers</var>, either by adding peers that are not yet in <var>old-peers</var>
|
|
|
or updating the freshness of already known peers.
|
|
|
</p></dd></dl>
|
|
|
|
|
|
<dl>
|
|
|
<dt><a name="index-peer_002dfiber"></a>Scheme Procedure: <strong>peer-fiber</strong> <em><var>parent-channel</var> <var>peer</var> <var>peerid</var> <var>infohash</var> <var>bitfield</var></em></dt>
|
|
|
<dd><p>Runs a fiber that connects to a peer, listens for commands and reports peer
|
|
|
status. This fiber runs indefinitely until it receives a <code>'quit</code> signal
|
|
|
on its private channel.
|
|
|
</p>
|
|
|
<p><var>parent-channel</var> is the channel to which the fiber should report changes
|
|
|
to the current peer. These messages are are either
|
|
|
<code>`(("type" peer) ("peer" <var>peer</var>))</code> to report either a new connection or
|
|
|
an update to the peer fields, or <code>`(("type" peer-closed) ("peer" <var>peer</var>))</code>
|
|
|
to signal the peer is disconnected and should not be taken into account anymore.
|
|
|
This last message is given only when the fiber stops unexpectedly after it
|
|
|
advertised a new peer. If an error occured before the connection could be
|
|
|
advertised to the <var>parent-channel</var>, no message is sent to the channel.
|
|
|
</p>
|
|
|
<p><var>peer</var> is a <code>potential-peer</code> whose <var>host</var> and <var>port</var> fields
|
|
|
are used to connect to the peer it represents. <var>peerid</var> is the peer ID of
|
|
|
this client. <var>infohash</var> is the infohash of the torrent that should be
|
|
|
recovered from that peer and <var>bitfield</var> is the bitfield representation of
|
|
|
the pieces we have and don’t have yet.
|
|
|
</p></dd></dl>
|
|
|
|
|
|
<hr>
|
|
|
<a name="Reading-and-Writing-Downloaded-Files"></a>
|
|
|
<div class="header">
|
|
|
<p>
|
|
|
Previous: <a href="#Sending-and-Receiving-Messages" accesskey="p" rel="prev">Sending and Receiving Messages</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
|
|
|
</div>
|
|
|
<a name="Reading-and-Writing-Downloaded-Files-1"></a>
|
|
|
<h2 class="chapter">5 Reading and Writing Downloaded Files</h2>
|
|
|
|
|
|
<p>The <code>(torrent files)</code> module is responsible for handling downloaded files.
|
|
|
It contains procedures to read, write and check pieces to one or more files.
|
|
|
</p>
|
|
|
<dl>
|
|
|
<dt><a name="index-check_002dpiece"></a>Scehem Procedure: <strong>check-piece</strong> <em><var>piece-data</var> <var>sha1</var></em></dt>
|
|
|
<dd><p>Returns whether <var>piece-data</var> contains the data whose hash is <var>sha1</var>.
|
|
|
</p></dd></dl>
|
|
|
|
|
|
<dl>
|
|
|
<dt><a name="index-create_002dempty_002dfile"></a>Scheme Procedure: <strong>create-empty-file</strong> <em><var>filename</var> <var>size</var></em></dt>
|
|
|
<dd><p>Creates <samp>filename</samp> and fill it with <var>size</var> null bytes.
|
|
|
</p></dd></dl>
|
|
|
|
|
|
<dl>
|
|
|
<dt><a name="index-get_002dblock"></a>Scheme Procedure: <strong>get-block</strong> <em><var>file</var> <var>position</var> <var>size</var></em></dt>
|
|
|
<dd><p>Read <var>size</var> bytes in <var>filename</var> from position <var>position</var> (in
|
|
|
bytes from the beginning of the file).
|
|
|
</p></dd></dl>
|
|
|
|
|
|
<dl>
|
|
|
<dt><a name="index-get_002drepresentation"></a>Scheme Procedure: <strong>get-representation</strong> <em><var>piece-size</var> <var>pieces</var> <var>filename</var></em></dt>
|
|
|
<dd><p>Returns a list of booleans representing the state of the file: <var>#t</var> for a
|
|
|
complete block, <code>#f</code> for a missing block.
|
|
|
</p></dd></dl>
|
|
|
|
|
|
<dl>
|
|
|
<dt><a name="index-get_002drepresentation_002dmultiple"></a>Scheme Procedure: <strong>get-representation-multiple</strong> <em><var>piece-size</var> <var>pieces</var> <var>files</var> </em></dt>
|
|
|
<dd><p>Returns a list of booleans representing the state of the files: <var>#t</var> for a
|
|
|
complete block, <code>#f</code> for a missing block.
|
|
|
</p></dd></dl>
|
|
|
|
|
|
<dl>
|
|
|
<dt><a name="index-put_002dblock"></a>Scheme Procedure: <strong>put-block</strong> <em><var>filename</var> <var>block-data</var> <var>position</var></em></dt>
|
|
|
<dd><p>Write <var>block-data</var>, a bytevector, into <var>filename</var> starting at position
|
|
|
<var>position</var> (in bytes from the beginning of the file).
|
|
|
</p></dd></dl> |
|
|
\ No newline at end of file |