chiark / gitweb /
debian/control: Add Build-Depends for `dh-python'.
[mLib-python] / conn.pyx
index 2b3e0bc755d611df068e9ad2b26c46a2f0d7c768..2f5d4939e05e7dcdd7668d7b5645530e93bc18ba 100644 (file)
--- a/conn.pyx
+++ b/conn.pyx
 ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 cdef class SelConnect:
+  """
+  SelConnect(SK, [connectedproc = FUNC], [errorproc = FUNC])
+
+  When socket SK connects, call CONNECTEDPROC(); if connection fails, call
+  ERRORPROC(ERRNO, MESSAGE).
+
+  Attributes: C.socket, C.activep, C.connectedproc, C.errorproc.
+  """
   cdef conn c
   cdef int _activep
   cdef readonly object socket
@@ -40,9 +48,11 @@ cdef class SelConnect:
     if me._activep:
       conn_kill(&me.c)
   property activep:
+    """C.activep -> BOOL: is connection still in progress?"""
     def __get__(me):
       return _tobool(me._activep)
   property connectedproc:
+    """C.connectedproc -> FUNC: call FUNC() when connection completes"""
     def __get__(me):
       return me._connected
     def __set__(me, proc):
@@ -50,6 +60,9 @@ cdef class SelConnect:
     def __del__(me):
       me._connected = None
   property errorproc:
+    """
+    C.errorproc -> FUNC: call FUNC(ERRNO, MSG) if connection fails
+    """
     def __get__(me):
       return me._error
     def __set__(me, proc):
@@ -57,6 +70,7 @@ cdef class SelConnect:
     def __del__(me):
       me._error = None
   def kill(me):
+    """C.kill(): give up on connection"""
     if not me._activep:
       raise ValueError, 'already dead'
     conn_kill(&me.c);
@@ -66,10 +80,13 @@ cdef class SelConnect:
     me._activep = 0
     me.dead()
   def dead(me):
+    """C.dead(): called when connection completes or fails"""
     pass
   def connected(me):
+    """C.connected(): called when connection completes successfully"""
     return _maybecall(me._connected, ())
   def error(me, errno, strerror):
+    """C.error(ERRNO, MSG): called when connection fails"""
     return _maybecall(me._error, ())
 
 cdef void _connfunc(int fd, void *arg):