ホーム › Networking.WinSock › IN6_ADDR
IN6_ADDR
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| u | _u_e__Union | 16 | +0 | +0 | 128ビットのIPv6アドレスをバイト/ワード配列で表す無名共用体である。 |
共用体: _u_e__Union x64 16B / x86 16B
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| Byte | BYTE | 16 | +0 | +0 |
| Word | WORD | 16 | +0 | +0 |
各言語での定義
#include <windows.h>
// IN6_ADDR (x64 16 / x86 16 バイト)
typedef struct IN6_ADDR {
_u_e__Union u;
} IN6_ADDR;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IN6_ADDR
{
public _u_e__Union u;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IN6_ADDR
Public u As _u_e__Union
End Structureimport ctypes
from ctypes import wintypes
class IN6_ADDR(ctypes.Structure):
_fields_ = [
("u", _u_e__Union),
]#[repr(C)]
pub struct IN6_ADDR {
pub u: _u_e__Union,
}import "golang.org/x/sys/windows"
type IN6_ADDR struct {
u _u_e__Union
}type
IN6_ADDR = record
u: _u_e__Union;
end;const IN6_ADDR = extern struct {
u: _u_e__Union,
};type
IN6_ADDR {.bycopy.} = object
u: _u_e__Unionstruct IN6_ADDR
{
_u_e__Union u;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; IN6_ADDR サイズ: 16 バイト(x64)
dim st, 4 ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; u : _u_e__Union (+0, 16byte) varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global IN6_ADDR
#field byte u 16
#endstruct
stdim st, IN6_ADDR ; NSTRUCT 変数を確保
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。