author | Tero Marttila <terom@fixme.fi> |
Fri, 25 Sep 2009 21:34:04 +0300 | |
changeset 49 | e2f79e68418a |
permissions | -rw-r--r-- |
49
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
1 |
""" |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
2 |
Internal module to keep the abstract sockaddr types out of the address module, which must contain backreferences to |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
3 |
the concrete implementations. |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
4 |
""" |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
5 |
|
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
6 |
cimport qmsk.net.socket.platform as platform |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
7 |
|
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
8 |
cdef class sockaddr : |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
9 |
""" |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
10 |
A network-level socket address |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
11 |
|
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
12 |
XXX: not abstract enough. Functions/properties like getnameinfo/addr/port do not work for e.g. sockaddr_un |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
13 |
|
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
14 |
>>> sockaddr().family |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
15 |
0 |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
16 |
>>> sockaddr().port |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
17 |
Traceback (most recent call last): |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
18 |
... |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
19 |
NotImplementedError |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
20 |
>>> sockaddr().getnameinfo() |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
21 |
Traceback (most recent call last): |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
22 |
... |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
23 |
NotImplementedError |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
24 |
""" |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
25 |
|
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
26 |
# address family |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
27 |
# XXX: this should be a class constant! It's part of our type safety! |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
28 |
cdef readonly platform.sa_family_t family |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
29 |
|
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
30 |
cdef void _init_family (self, platform.sa_family_t family = ?) |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
31 |
|
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
32 |
# get the sockaddr/socklen |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
33 |
# each of these can be NULL to ignore it |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
34 |
cdef int _get_sockaddr (self, platform.sockaddr **sa_ptr, platform.socklen_t *sa_len) except -1 |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
35 |
|
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
36 |
cdef platform.sockaddr* _get_sockaddr_ptr (self) except NULL |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
37 |
cdef platform.socklen_t _get_sockaddr_len (self) except -1 |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
38 |
|
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
39 |
# set the sockaddr, socklen must match |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
40 |
cdef int _set_sockaddr (self, platform.sockaddr *sa, size_t sa_len) except -1 |
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
41 |
|
e2f79e68418a
fix up circular cimports related to the sockaddr type, and touch up endpoint/getaddrinfo a bit
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
42 |