왜 sockaddr_storage가 정확히 128 바이트인지 궁금합니다. 나는 그것이 IPv6를 위해 적어도 28 바이트가되어야한다는 것을 이해한다. 그러나 이것은 sockaddr_in6보다 100 여분의 바이트가 더 많도록 약간 과장된 것으로 보인다. 스토리지 구조체를 미래에 증명할 수 있을까요? 아니면 지금 당장 필요로하는 이유가 있습니까?sockaddr_storage size of 128 bytes
4
A
답변
3
§3.10의 질문에 대한 답변은 rfc 2553이고이 부분은 SO post입니다.
이유는 적어도 효율 정렬 IP6와 다른 프로토콜 데이터및 64 비트를 보유한다 의 조합이다. 은 RFC의 관련 부분에서
: 응용 프로그램작가를 도울 수있는 소켓 API에
하나의 간단한 추가는 "구조체 sockaddr_storage"입니다. 이 데이터 구조는
코드를 사용하여 여러 주소 패밀리에서 이식 가능한 코드 작성을 간소화하고
플랫폼 일 수 있습니다. 이 데이터 구조는 다음 목표로 설계되었습니다.- It has a large enough implementation specific maximum size to store the desired set of protocol specific socket address data structures. Specifically, it is at least large enough to accommodate sockaddr_in and sockaddr_in6 and possibly other protocol specific socket addresses too. - It is aligned at an appropriate boundary so protocol specific socket address data structure pointers can be cast to it and access their fields without alignment problems. (e.g. pointers to sockaddr_in6 and/or sockaddr_in can be cast to it and access fields without alignment problems). - It has the initial field(s) isomorphic to the fields of the "struct sockaddr" data structure on that implementation which can be used as a discriminants for deriving the protocol in use. These initial field(s) would on most implementations either be a single field of type "sa_family_t" (isomorphic to sa_family field, 16 bits) or two fields of type uint8_t and sa_family_t respectively, (isomorphic to sa_len and sa_family_t, 8 bits each).
2
이 구조에도 struct sockaddr_un
을 넣을 수있는 시스템이있을 수 있습니다. 후자는 약 100-110 자의 시스템 종속 경로 길이를가집니다. 그리고 128은 아름답게 짝수입니다.
관련 문제
- 1. lexicographic unknown unknown bytes size - in c
- 2. HornetQClient에서 max-size-bytes 및 address-full-policy 설정
- 3. API를 사용하여 sockaddr_storage
- 4. 허용 된 메모리 크기 * exhausted, bytes of PHP
- 5. ABC 128 with CBC
- 6. OCaml Bytes to Bigarray
- 7. tinyint (size), varchar (size) : "size"설명
- 8. ASN에서 SIZE OF 연산자를 다른 변수와 결합하는 방법은 무엇입니까?
- 9. C 소켓 추측 sockaddr 및 sockaddr_storage
- 10. sockaddr의 sockaddr_storage 또는 sockaddr_in6 보유 방법은 무엇입니까?
- 11. bytes lose 소켓 프로그래밍
- 12. "Map output materialized bytes"vs "map output bytes"
- 13. Data.Binary.decodeFile을 사용하여 "demandInput : bytes not enough bytes"오류가 발생했습니다.
- 14. "Bytes (Offset Hex text)"
- 15. Struct.Error, Bytes 객체 여야합니까?
- 16. rest-to-image-bytes
- 17. throw Bytes OverFlow
- 18. bytes 배열을 이미지로 변환합니다.
- 19. 사용`bytes` 3
- 20. Bytes from BluetoothGatt
- 21. serialport2에서 node.js가있는 파이썬 bytes()
- 22. Zxing : 128 개의 바코드와 GSI-128 구분
- 23. AES 128 암호 해독 실패
- 24. 128 비트 정밀도의 Lapack 사용
- 25. Titanium.Media.openPhotoGallery/allowEditing size
- 26. 파이썬에서 128 비트 정수를 인코딩합니까?
- 27. Ofstream writting too many bytes
- 28. Python hashlib & Bytes 객체의 decode()
- 29. Webservice Bytes [] - PHP에서 어떻게 전송합니까?
- 30. arraylist of arraylist of
은'구조체 sockaddr_atmsvc' 얼마나 큰? 나도 몰라,하지만 나는 28 바이트 이상을 걸었다. –