1
socket.inet_pton에 의해 반환 된 데이터의 16 바이트 blob을 부호없는 바이트의 ctypes 배열로 변환하려고합니다.파이썬 ctypes 배열 캐스팅
class in6_addr(ctypes.Structure): _fields_ = (("Byte", ctypes.c_ubyte * 16),)
을 그리고 방울은 다음과 같습니다 : 내 데이터 구조는 다음과 같습니다
data = socket.inet_pton(socket.AF_INET6, "2001::3")
그러나, 이러한 시도는 오류를 얻을 :
sin6 = in6_addr() # TypeError: expected c_ubyte_Array_16 instance, got str sin6.Byte = data # TypeError: cast() argument 2 must be a pointer type, not c_ubyte_Array_16 sin6.Byte = ctypes.cast(data, ctypes.c_ubyte * 16) # TypeError: incompatible types, LP_c_ubyte instance instead of c_ubyte_Array_16 instance sin6.Byte = ctypes.cast(data, ctypes.POINTER(ctypes.c_ubyte))
모든 코드 : http://codepad.org/2cjyVXBA
어떤 유형으로 전송해야 하나?