X-Git-Url: https://git.distorted.org.uk/~mdw/mLib-python/blobdiff_plain/5b1830f325c55c70d65fd020f08dd958493e528d..HEAD:/conn.pyx diff --git a/conn.pyx b/conn.pyx index 2b3e0bc..2f5d493 100644 --- a/conn.pyx +++ b/conn.pyx @@ -24,6 +24,14 @@ ### 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):