136 lines
9.3 KiB
HTML
136 lines
9.3 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<html><head><title>Python: class StreamHandler</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
</head><body bgcolor="#f0f0f8">
|
|
<p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><strong>start.StreamHandler</strong> = <a name="start.StreamHandler">class StreamHandler</a>(<a href="threading.html#Thread">threading.Thread</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>this class can receive files sent by p2p<br>
|
|
to run this class, we need to do :<br>
|
|
s = StreamHandler(portFile, fileName)<br>
|
|
s.<a href="#start.StreamHandler-start">start</a>()<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%"><dl><dt>Method resolution order:</dt>
|
|
<dd><a href="start.html#StreamHandler">StreamHandler</a></dd>
|
|
<dd><a href="threading.html#Thread">threading.Thread</a></dd>
|
|
<dd><a href="builtins.html#object">builtins.object</a></dd>
|
|
</dl>
|
|
<hr>
|
|
Methods defined here:<br>
|
|
<dl><dt><a name="StreamHandler-__init__"><strong>__init__</strong></a>(self, port, filename)</dt><dd><tt>:param port: the port of the new connection<br>
|
|
:param filename: the name of the file you wish to receive<br>
|
|
:return:</tt></dd></dl>
|
|
|
|
<dl><dt><a name="StreamHandler-acceptcsock"><strong>acceptcsock</strong></a>(self)</dt><dd><tt>accept to receive the file<br>
|
|
:return:</tt></dd></dl>
|
|
|
|
<dl><dt><a name="StreamHandler-acceptmsock"><strong>acceptmsock</strong></a>(self)</dt><dd><tt>Get the address of the connection<br>
|
|
:return:</tt></dd></dl>
|
|
|
|
<dl><dt><a name="StreamHandler-bindmsock"><strong>bindmsock</strong></a>(self)</dt><dd><tt>creation of a new socket for the p2p transfert file<br>
|
|
:return:</tt></dd></dl>
|
|
|
|
<dl><dt><a name="StreamHandler-close"><strong>close</strong></a>(self)</dt><dd><tt>We close the connection<br>
|
|
:return:</tt></dd></dl>
|
|
|
|
<dl><dt><a name="StreamHandler-process"><strong>process</strong></a>(self)</dt><dd><tt>function who start all the function<br>
|
|
:return:</tt></dd></dl>
|
|
|
|
<dl><dt><a name="StreamHandler-run"><strong>run</strong></a>(self)</dt><dd><tt> Execute the process function<br>
|
|
:return:</tt></dd></dl>
|
|
|
|
<dl><dt><a name="StreamHandler-transfer"><strong>transfer</strong></a>(self)</dt><dd><tt>Starting the transfert of the file<br>
|
|
:return:</tt></dd></dl>
|
|
|
|
<hr>
|
|
Methods inherited from <a href="threading.html#Thread">threading.Thread</a>:<br>
|
|
<dl><dt><a name="StreamHandler-__repr__"><strong>__repr__</strong></a>(self)</dt></dl>
|
|
|
|
<dl><dt><a name="StreamHandler-getName"><strong>getName</strong></a>(self)</dt></dl>
|
|
|
|
<dl><dt><a name="StreamHandler-isAlive"><strong>isAlive</strong></a> = is_alive(self)</dt><dd><tt>Return whether the thread is alive.<br>
|
|
<br>
|
|
This method returns True just before the <a href="#start.StreamHandler-run">run</a>() method starts until just<br>
|
|
after the <a href="#start.StreamHandler-run">run</a>() method terminates. The module function enumerate()<br>
|
|
returns a list of all alive threads.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="StreamHandler-isDaemon"><strong>isDaemon</strong></a>(self)</dt></dl>
|
|
|
|
<dl><dt><a name="StreamHandler-is_alive"><strong>is_alive</strong></a>(self)</dt><dd><tt>Return whether the thread is alive.<br>
|
|
<br>
|
|
This method returns True just before the <a href="#start.StreamHandler-run">run</a>() method starts until just<br>
|
|
after the <a href="#start.StreamHandler-run">run</a>() method terminates. The module function enumerate()<br>
|
|
returns a list of all alive threads.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="StreamHandler-join"><strong>join</strong></a>(self, timeout=None)</dt><dd><tt>Wait until the thread terminates.<br>
|
|
<br>
|
|
This blocks the calling thread until the thread whose <a href="#start.StreamHandler-join">join</a>() method is<br>
|
|
called terminates -- either normally or through an unhandled exception<br>
|
|
or until the optional timeout occurs.<br>
|
|
<br>
|
|
When the timeout argument is present and not None, it should be a<br>
|
|
floating point number specifying a timeout for the operation in seconds<br>
|
|
(or fractions thereof). As <a href="#start.StreamHandler-join">join</a>() always returns None, you must call<br>
|
|
<a href="#start.StreamHandler-isAlive">isAlive</a>() after <a href="#start.StreamHandler-join">join</a>() to decide whether a timeout happened -- if the<br>
|
|
thread is still alive, the <a href="#start.StreamHandler-join">join</a>() call timed out.<br>
|
|
<br>
|
|
When the timeout argument is not present or None, the operation will<br>
|
|
block until the thread terminates.<br>
|
|
<br>
|
|
A thread can be <a href="#start.StreamHandler-join">join</a>()ed many times.<br>
|
|
<br>
|
|
<a href="#start.StreamHandler-join">join</a>() raises a RuntimeError if an attempt is made to join the current<br>
|
|
thread as that would cause a deadlock. It is also an error to <a href="#start.StreamHandler-join">join</a>() a<br>
|
|
thread before it has been started and attempts to do so raises the same<br>
|
|
exception.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="StreamHandler-setDaemon"><strong>setDaemon</strong></a>(self, daemonic)</dt></dl>
|
|
|
|
<dl><dt><a name="StreamHandler-setName"><strong>setName</strong></a>(self, name)</dt></dl>
|
|
|
|
<dl><dt><a name="StreamHandler-start"><strong>start</strong></a>(self)</dt><dd><tt>Start the thread's activity.<br>
|
|
<br>
|
|
It must be called at most once per thread object. It arranges for the<br>
|
|
object's <a href="#start.StreamHandler-run">run</a>() method to be invoked in a separate thread of control.<br>
|
|
<br>
|
|
This method will raise a RuntimeError if called more than once on the<br>
|
|
same thread object.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data descriptors inherited from <a href="threading.html#Thread">threading.Thread</a>:<br>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>daemon</strong></dt>
|
|
<dd><tt>A boolean value indicating whether this thread is a daemon thread.<br>
|
|
<br>
|
|
This must be set before start() is called, otherwise RuntimeError is<br>
|
|
raised. Its initial value is inherited from the creating thread; the<br>
|
|
main thread is not a daemon thread and therefore all threads created in<br>
|
|
the main thread default to daemon = False.<br>
|
|
<br>
|
|
The entire Python program exits when no alive non-daemon threads are<br>
|
|
left.</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>ident</strong></dt>
|
|
<dd><tt>Thread identifier of this thread or None if it has not been started.<br>
|
|
<br>
|
|
This is a nonzero integer. See the thread.get_ident() function. Thread<br>
|
|
identifiers may be recycled when a thread exits and another thread is<br>
|
|
created. The identifier is available even after the thread has exited.</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>name</strong></dt>
|
|
<dd><tt>A string used for identification purposes only.<br>
|
|
<br>
|
|
It has no semantics. Multiple threads may be given the same name. The<br>
|
|
initial name is set by the constructor.</tt></dd>
|
|
</dl>
|
|
</td></tr></table>
|
|
</body></html> |