ホーム › Networking.WinSock › ADDRINFOW
ADDRINFOW
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| ai_flags | INT | 4 | +0 | +0 | アドレス取得時の動作を制御するフラグである。AI_PASSIVE等。 |
| ai_family | INT | 4 | +4 | +4 | アドレスファミリである。AF_INET/AF_INET6等。 |
| ai_socktype | INT | 4 | +8 | +8 | ソケットタイプである。SOCK_STREAM/SOCK_DGRAM等。 |
| ai_protocol | INT | 4 | +12 | +12 | プロトコルである。IPPROTO_TCP等。 |
| ai_addrlen | UINT_PTR | 8/4 | +16 | +16 | ai_addrが指すアドレスの長さをバイト単位で示す。 |
| ai_canonname | LPWSTR | 8/4 | +24 | +20 | 正規ホスト名(canonical name)文字列(Unicode)である。NULL可。 |
| ai_addr | SOCKADDR* | 8/4 | +32 | +24 | SOCKADDR構造体へのポインタである。 |
| ai_next | ADDRINFOW* | 8/4 | +40 | +28 | 次のADDRINFOWエントリへのポインタである。NULLで終端。 |
各言語での定義
#include <windows.h>
// ADDRINFOW (x64 48 / x86 32 バイト)
typedef struct ADDRINFOW {
INT ai_flags;
INT ai_family;
INT ai_socktype;
INT ai_protocol;
UINT_PTR ai_addrlen;
LPWSTR ai_canonname;
SOCKADDR* ai_addr;
ADDRINFOW* ai_next;
} ADDRINFOW;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ADDRINFOW
{
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_next;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ADDRINFOW
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_next As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class ADDRINFOW(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_next", ctypes.c_void_p),
]#[repr(C)]
pub struct ADDRINFOW {
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_next: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type ADDRINFOW struct {
ai_flags int32
ai_family int32
ai_socktype int32
ai_protocol int32
ai_addrlen uintptr
ai_canonname uintptr
ai_addr uintptr
ai_next uintptr
}type
ADDRINFOW = record
ai_flags: Integer;
ai_family: Integer;
ai_socktype: Integer;
ai_protocol: Integer;
ai_addrlen: NativeUInt;
ai_canonname: Pointer;
ai_addr: Pointer;
ai_next: Pointer;
end;const ADDRINFOW = extern struct {
ai_flags: i32,
ai_family: i32,
ai_socktype: i32,
ai_protocol: i32,
ai_addrlen: usize,
ai_canonname: ?*anyopaque,
ai_addr: ?*anyopaque,
ai_next: ?*anyopaque,
};type
ADDRINFOW {.bycopy.} = object
ai_flags: int32
ai_family: int32
ai_socktype: int32
ai_protocol: int32
ai_addrlen: uint
ai_canonname: pointer
ai_addr: pointer
ai_next: pointerstruct ADDRINFOW
{
int ai_flags;
int ai_family;
int ai_socktype;
int ai_protocol;
size_t ai_addrlen;
void* ai_canonname;
void* ai_addr;
void* ai_next;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; ADDRINFOW サイズ: 32 バイト(x86)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 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_next : ADDRINFOW* (+28, 4byte) varptr(st)+28 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; ADDRINFOW サイズ: 48 バイト(x64)
dim st, 12 ; 4byte整数×12(構造体サイズ 48 / 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_next : ADDRINFOW* (+40, 8byte) varptr(st)+40 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global ADDRINFOW
#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_next
#endstruct
stdim st, ADDRINFOW ; NSTRUCT 変数を確保
st->ai_flags = 100
mes "ai_flags=" + st->ai_flags