Win32 API 日本語リファレンス
ホームNetworking.WinSock › ADDRINFOEX2W

ADDRINFOEX2W

構造体
サイズx64: 88 バイト / x86: 52 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
ai_flagsINT4+0+0アドレス取得時の動作を制御するフラグである。
ai_familyINT4+4+4アドレスファミリである。AF_INET/AF_INET6等。
ai_socktypeINT4+8+8ソケットタイプである。SOCK_STREAM/SOCK_DGRAM等。
ai_protocolINT4+12+12プロトコルである。IPPROTO_TCP等。
ai_addrlenUINT_PTR8/4+16+16ai_addrが指すアドレスの長さをバイト単位で示す。
ai_canonnameLPWSTR8/4+24+20正規ホスト名文字列(Unicode)である。NULL可。
ai_addrSOCKADDR*8/4+32+24SOCKADDR構造体へのポインタである。
ai_blobvoid*8/4+40+28名前空間プロバイダ固有のデータブロブへのポインタである。NULL可。
ai_bloblenUINT_PTR8/4+48+32ai_blobのサイズをバイト単位で示す。
ai_providerGUID*8/4+56+36名前空間プロバイダを識別するGUIDへのポインタである。
ai_nextADDRINFOEX2W*8/4+64+40次のADDRINFOEX2Wエントリへのポインタである。NULLで終端。
ai_versionINT4+72+44この構造体のバージョン番号である。
ai_fqdnLPWSTR8/4+80+48解決された完全修飾ドメイン名(FQDN)文字列である。

各言語での定義

#include <windows.h>

// ADDRINFOEX2W  (x64 88 / x86 52 バイト)
typedef struct ADDRINFOEX2W {
    INT ai_flags;
    INT ai_family;
    INT ai_socktype;
    INT ai_protocol;
    UINT_PTR ai_addrlen;
    LPWSTR ai_canonname;
    SOCKADDR* ai_addr;
    void* ai_blob;
    UINT_PTR ai_bloblen;
    GUID* ai_provider;
    ADDRINFOEX2W* ai_next;
    INT ai_version;
    LPWSTR ai_fqdn;
} ADDRINFOEX2W;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ADDRINFOEX2W
{
    public int ai_flags;
    public int ai_family;
    public int ai_socktype;
    public int ai_protocol;
    public UIntPtr ai_addrlen;
    public IntPtr ai_canonname;
    public IntPtr ai_addr;
    public IntPtr ai_blob;
    public UIntPtr ai_bloblen;
    public IntPtr ai_provider;
    public IntPtr ai_next;
    public int ai_version;
    public IntPtr ai_fqdn;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ADDRINFOEX2W
    Public ai_flags As Integer
    Public ai_family As Integer
    Public ai_socktype As Integer
    Public ai_protocol As Integer
    Public ai_addrlen As UIntPtr
    Public ai_canonname As IntPtr
    Public ai_addr As IntPtr
    Public ai_blob As IntPtr
    Public ai_bloblen As UIntPtr
    Public ai_provider As IntPtr
    Public ai_next As IntPtr
    Public ai_version As Integer
    Public ai_fqdn As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class ADDRINFOEX2W(ctypes.Structure):
    _fields_ = [
        ("ai_flags", ctypes.c_int),
        ("ai_family", ctypes.c_int),
        ("ai_socktype", ctypes.c_int),
        ("ai_protocol", ctypes.c_int),
        ("ai_addrlen", ctypes.c_size_t),
        ("ai_canonname", ctypes.c_void_p),
        ("ai_addr", ctypes.c_void_p),
        ("ai_blob", ctypes.c_void_p),
        ("ai_bloblen", ctypes.c_size_t),
        ("ai_provider", ctypes.c_void_p),
        ("ai_next", ctypes.c_void_p),
        ("ai_version", ctypes.c_int),
        ("ai_fqdn", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct ADDRINFOEX2W {
    pub ai_flags: i32,
    pub ai_family: i32,
    pub ai_socktype: i32,
    pub ai_protocol: i32,
    pub ai_addrlen: usize,
    pub ai_canonname: *mut core::ffi::c_void,
    pub ai_addr: *mut core::ffi::c_void,
    pub ai_blob: *mut core::ffi::c_void,
    pub ai_bloblen: usize,
    pub ai_provider: *mut core::ffi::c_void,
    pub ai_next: *mut core::ffi::c_void,
    pub ai_version: i32,
    pub ai_fqdn: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type ADDRINFOEX2W struct {
	ai_flags int32
	ai_family int32
	ai_socktype int32
	ai_protocol int32
	ai_addrlen uintptr
	ai_canonname uintptr
	ai_addr uintptr
	ai_blob uintptr
	ai_bloblen uintptr
	ai_provider uintptr
	ai_next uintptr
	ai_version int32
	ai_fqdn uintptr
}
type
  ADDRINFOEX2W = record
    ai_flags: Integer;
    ai_family: Integer;
    ai_socktype: Integer;
    ai_protocol: Integer;
    ai_addrlen: NativeUInt;
    ai_canonname: Pointer;
    ai_addr: Pointer;
    ai_blob: Pointer;
    ai_bloblen: NativeUInt;
    ai_provider: Pointer;
    ai_next: Pointer;
    ai_version: Integer;
    ai_fqdn: Pointer;
  end;
const ADDRINFOEX2W = extern struct {
    ai_flags: i32,
    ai_family: i32,
    ai_socktype: i32,
    ai_protocol: i32,
    ai_addrlen: usize,
    ai_canonname: ?*anyopaque,
    ai_addr: ?*anyopaque,
    ai_blob: ?*anyopaque,
    ai_bloblen: usize,
    ai_provider: ?*anyopaque,
    ai_next: ?*anyopaque,
    ai_version: i32,
    ai_fqdn: ?*anyopaque,
};
type
  ADDRINFOEX2W {.bycopy.} = object
    ai_flags: int32
    ai_family: int32
    ai_socktype: int32
    ai_protocol: int32
    ai_addrlen: uint
    ai_canonname: pointer
    ai_addr: pointer
    ai_blob: pointer
    ai_bloblen: uint
    ai_provider: pointer
    ai_next: pointer
    ai_version: int32
    ai_fqdn: pointer
struct ADDRINFOEX2W
{
    int ai_flags;
    int ai_family;
    int ai_socktype;
    int ai_protocol;
    size_t ai_addrlen;
    void* ai_canonname;
    void* ai_addr;
    void* ai_blob;
    size_t ai_bloblen;
    void* ai_provider;
    void* ai_next;
    int ai_version;
    void* ai_fqdn;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; ADDRINFOEX2W サイズ: 52 バイト(x86)
dim st, 13    ; 4byte整数×13(構造体サイズ 52 / 4 切り上げ)
; ai_flags : INT (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ai_family : INT (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ai_socktype : INT (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; ai_protocol : INT (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; ai_addrlen : UINT_PTR (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ai_canonname : LPWSTR (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; ai_addr : SOCKADDR* (+24, 4byte)  varptr(st)+24 を基点に操作(4byte:入れ子/配列)
; ai_blob : void* (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; ai_bloblen : UINT_PTR (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; ai_provider : GUID* (+36, 4byte)  varptr(st)+36 を基点に操作(4byte:入れ子/配列)
; ai_next : ADDRINFOEX2W* (+40, 4byte)  varptr(st)+40 を基点に操作(4byte:入れ子/配列)
; ai_version : INT (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; ai_fqdn : LPWSTR (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; ADDRINFOEX2W サイズ: 88 バイト(x64)
dim st, 22    ; 4byte整数×22(構造体サイズ 88 / 4 切り上げ)
; ai_flags : INT (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ai_family : INT (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ai_socktype : INT (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; ai_protocol : INT (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; ai_addrlen : UINT_PTR (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; ai_canonname : LPWSTR (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; ai_addr : SOCKADDR* (+32, 8byte)  varptr(st)+32 を基点に操作(8byte:入れ子/配列)
; ai_blob : void* (+40, 8byte)  qpoke st,40,値 / qpeek(st,40)  ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; ai_bloblen : UINT_PTR (+48, 8byte)  qpoke st,48,値 / qpeek(st,48)  ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; ai_provider : GUID* (+56, 8byte)  varptr(st)+56 を基点に操作(8byte:入れ子/配列)
; ai_next : ADDRINFOEX2W* (+64, 8byte)  varptr(st)+64 を基点に操作(8byte:入れ子/配列)
; ai_version : INT (+72, 4byte)  st.18 = 値  /  値 = st.18   (lpoke/lpeek も可)
; ai_fqdn : LPWSTR (+80, 8byte)  qpoke st,80,値 / qpeek(st,80)  ※IronHSPのみ。3.7/3.8は lpoke st,80,下位 : lpoke st,84,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global ADDRINFOEX2W
    #field int ai_flags
    #field int ai_family
    #field int ai_socktype
    #field int ai_protocol
    #field intptr ai_addrlen
    #field intptr ai_canonname
    #field intptr ai_addr
    #field intptr ai_blob
    #field intptr ai_bloblen
    #field intptr ai_provider
    #field intptr ai_next
    #field int ai_version
    #field intptr ai_fqdn
#endstruct

stdim st, ADDRINFOEX2W        ; NSTRUCT 変数を確保
st->ai_flags = 100
mes "ai_flags=" + st->ai_flags