sock/addr.pxd
author Tero Marttila <terom@fixme.fi>
Sun, 16 Aug 2009 04:15:07 +0300
changeset 4 664a1dfe08ac
parent 3 bbad9790b786
child 5 59bed837c265
permissions -rw-r--r--
moar fixes
cimport libc

cdef class sockaddr :
    """
        A network-level socket address

        >>> sockaddr().family
        0
        >>> sockaddr().port
        Traceback (most recent call last):
          ...
        NotImplementedError
        >>> sockaddr().getnameinfo()
        Traceback (most recent call last):
          ...
        NotImplementedError
    """
    
    # address family
    # XXX: this should be a class constant! It's part of our type safety!
    cdef readonly libc.sa_family_t family

    cdef void _init_family (self, libc.sa_family_t family=?)

    # get the sockaddr/socklen
    # each of these can be NULL to ignore it
    cdef int _get_sockaddr (self, libc.sockaddr **sa_ptr, libc.socklen_t *sa_len) except -1

    cdef libc.sockaddr* _get_sockaddr_ptr (self) except NULL
    cdef libc.socklen_t _get_sockaddr_len (self) except -1