This module implements inet_ntoa and inet_aton, and provides an interface to SockAddr services provided by the Zorp core.
from socket import htonl, ntohl
from string import split, atoi
Converts an internet address to a 32 bit integer
inet_aton ( ip ) |
splits on the dot, atoi the parts, and bitshift the whole thing into one
Table 4-116. Arguments for .inet_aton()
ip | A dotted-quad string |
unsigned long in network byte order
Converts a 32 bit integer into IP number's string representation
inet_ntoa ( ip ) |
Masks the necessary bytes out and formats them into a string.
Table 4-117. Arguments for .inet_ntoa()
ip | The ip number in 32 bit integer (network byte order) |
string representation of IP
This class encapsulates an IPv4 address:port pair, similar to the struct sockaddr_in in C. It is implemented and exported by the Zorp core.
Table 4-118. Attributes for class SockAddrInet
ip | ip address (network byte order) |
ip_s | ip address in string representation |
port | port number (network byte order) |
Specialized SockAddrInet class which allocates a new port within the given range of ports when a listener bounds to it.
Table 4-119. Attributes for class SockAddrInetRange
ip | ip address (network byte order) |
ip_s | ip address in string representation |
port | port number (network byte order) |