Closed dwtj closed 10 years ago
Yes. If you mean what I think you mean, you'll want something like this using the ipaddress module (Python 3 only -- Python 2 requires some stuff from pip):
>>> import ipaddress
>>> ipaddress.ip_address('127.0.0.1').packed
b'\x7f\x00x00\x01'
That is, an IPv{4,6}Address object has a packed attribute that is defined as:
The binary representation of this address - a bytes object of the appropriate length (most significant octet first). This is 4 bytes for IPv4 and 16 bytes for IPv6.
Thanks Nik, that's just what I needed.
Issue closed with 102ae62
SOCKSProtocol._sendReply()
is unfinished.Are there some standard helper functions for converting from IPv4 strings to a
bytes
object?