ホーム › Networking.WinSock › HOSTENT
HOSTENT
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| h_name | LPSTR | 8/4 | +0 | +0 | ホストの正式名称文字列である。 |
| h_aliases | CHAR** | 8/4 | +8 | +4 | ホストの別名文字列配列(NULL終端)へのポインタである。 |
| h_addrtype | SHORT | 2 | +16 | +8 | アドレスのタイプ(AF_INET等)を示す値である。 |
| h_length | SHORT | 2 | +18 | +10 | 各アドレスの長さをバイト単位で示す。 |
| h_addr_list | CHAR** | 8/4 | +24 | +12 | ホストアドレスの配列(NULL終端)へのポインタである。 |
各言語での定義
#include <windows.h>
// HOSTENT (x64 32 / x86 16 バイト)
typedef struct HOSTENT {
LPSTR h_name;
CHAR** h_aliases;
SHORT h_addrtype;
SHORT h_length;
CHAR** h_addr_list;
} HOSTENT;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct HOSTENT
{
public IntPtr h_name;
public IntPtr h_aliases;
public short h_addrtype;
public short h_length;
public IntPtr h_addr_list;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure HOSTENT
Public h_name As IntPtr
Public h_aliases As IntPtr
Public h_addrtype As Short
Public h_length As Short
Public h_addr_list As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class HOSTENT(ctypes.Structure):
_fields_ = [
("h_name", ctypes.c_void_p),
("h_aliases", ctypes.c_void_p),
("h_addrtype", ctypes.c_short),
("h_length", ctypes.c_short),
("h_addr_list", ctypes.c_void_p),
]#[repr(C)]
pub struct HOSTENT {
pub h_name: *mut core::ffi::c_void,
pub h_aliases: *mut core::ffi::c_void,
pub h_addrtype: i16,
pub h_length: i16,
pub h_addr_list: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type HOSTENT struct {
h_name uintptr
h_aliases uintptr
h_addrtype int16
h_length int16
h_addr_list uintptr
}type
HOSTENT = record
h_name: Pointer;
h_aliases: Pointer;
h_addrtype: Smallint;
h_length: Smallint;
h_addr_list: Pointer;
end;const HOSTENT = extern struct {
h_name: ?*anyopaque,
h_aliases: ?*anyopaque,
h_addrtype: i16,
h_length: i16,
h_addr_list: ?*anyopaque,
};type
HOSTENT {.bycopy.} = object
h_name: pointer
h_aliases: pointer
h_addrtype: int16
h_length: int16
h_addr_list: pointerstruct HOSTENT
{
void* h_name;
void* h_aliases;
short h_addrtype;
short h_length;
void* h_addr_list;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; HOSTENT サイズ: 16 バイト(x86)
dim st, 4 ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; h_name : LPSTR (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; h_aliases : CHAR** (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; h_addrtype : SHORT (+8, 2byte) wpoke st,8,値 / 値 = wpeek(st,8)
; h_length : SHORT (+10, 2byte) wpoke st,10,値 / 値 = wpeek(st,10)
; h_addr_list : CHAR** (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; HOSTENT サイズ: 32 バイト(x64)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; h_name : LPSTR (+0, 8byte) qpoke st,0,値 / qpeek(st,0) ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; h_aliases : CHAR** (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; h_addrtype : SHORT (+16, 2byte) wpoke st,16,値 / 値 = wpeek(st,16)
; h_length : SHORT (+18, 2byte) wpoke st,18,値 / 値 = wpeek(st,18)
; h_addr_list : CHAR** (+24, 8byte) qpoke st,24,値 / qpeek(st,24) ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global HOSTENT
#field intptr h_name
#field intptr h_aliases
#field short h_addrtype
#field short h_length
#field intptr h_addr_list
#endstruct
stdim st, HOSTENT ; NSTRUCT 変数を確保
st->h_addrtype = 100
mes "h_addrtype=" + st->h_addrtype