ホーム › Networking.WinSock › PROTOCOL_INFOA
PROTOCOL_INFOA
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dwServiceFlags | DWORD | 4 | +0 | +0 | プロトコルが提供するサービス特性を示すフラグのビットマスク。 |
| iAddressFamily | INT | 4 | +4 | +4 | プロトコルが属するアドレスファミリを示す。 |
| iMaxSockAddr | INT | 4 | +8 | +8 | ソケットアドレスの最大バイト長を示す。 |
| iMinSockAddr | INT | 4 | +12 | +12 | ソケットアドレスの最小バイト長を示す。 |
| iSocketType | INT | 4 | +16 | +16 | ソケット種別(SOCK_STREAM等)を示す。 |
| iProtocol | INT | 4 | +20 | +20 | プロトコル番号を示す。 |
| dwMessageSize | DWORD | 4 | +24 | +24 | プロトコルが扱える最大メッセージサイズをバイト単位で示す。 |
| lpProtocol | LPSTR | 8/4 | +32 | +28 | プロトコル名を表すANSI文字列へのポインタ。 |
各言語での定義
#include <windows.h>
// PROTOCOL_INFOA (x64 40 / x86 32 バイト)
typedef struct PROTOCOL_INFOA {
DWORD dwServiceFlags;
INT iAddressFamily;
INT iMaxSockAddr;
INT iMinSockAddr;
INT iSocketType;
INT iProtocol;
DWORD dwMessageSize;
LPSTR lpProtocol;
} PROTOCOL_INFOA;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PROTOCOL_INFOA
{
public uint dwServiceFlags;
public int iAddressFamily;
public int iMaxSockAddr;
public int iMinSockAddr;
public int iSocketType;
public int iProtocol;
public uint dwMessageSize;
public IntPtr lpProtocol;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PROTOCOL_INFOA
Public dwServiceFlags As UInteger
Public iAddressFamily As Integer
Public iMaxSockAddr As Integer
Public iMinSockAddr As Integer
Public iSocketType As Integer
Public iProtocol As Integer
Public dwMessageSize As UInteger
Public lpProtocol As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class PROTOCOL_INFOA(ctypes.Structure):
_fields_ = [
("dwServiceFlags", wintypes.DWORD),
("iAddressFamily", ctypes.c_int),
("iMaxSockAddr", ctypes.c_int),
("iMinSockAddr", ctypes.c_int),
("iSocketType", ctypes.c_int),
("iProtocol", ctypes.c_int),
("dwMessageSize", wintypes.DWORD),
("lpProtocol", ctypes.c_void_p),
]#[repr(C)]
pub struct PROTOCOL_INFOA {
pub dwServiceFlags: u32,
pub iAddressFamily: i32,
pub iMaxSockAddr: i32,
pub iMinSockAddr: i32,
pub iSocketType: i32,
pub iProtocol: i32,
pub dwMessageSize: u32,
pub lpProtocol: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type PROTOCOL_INFOA struct {
dwServiceFlags uint32
iAddressFamily int32
iMaxSockAddr int32
iMinSockAddr int32
iSocketType int32
iProtocol int32
dwMessageSize uint32
lpProtocol uintptr
}type
PROTOCOL_INFOA = record
dwServiceFlags: DWORD;
iAddressFamily: Integer;
iMaxSockAddr: Integer;
iMinSockAddr: Integer;
iSocketType: Integer;
iProtocol: Integer;
dwMessageSize: DWORD;
lpProtocol: Pointer;
end;const PROTOCOL_INFOA = extern struct {
dwServiceFlags: u32,
iAddressFamily: i32,
iMaxSockAddr: i32,
iMinSockAddr: i32,
iSocketType: i32,
iProtocol: i32,
dwMessageSize: u32,
lpProtocol: ?*anyopaque,
};type
PROTOCOL_INFOA {.bycopy.} = object
dwServiceFlags: uint32
iAddressFamily: int32
iMaxSockAddr: int32
iMinSockAddr: int32
iSocketType: int32
iProtocol: int32
dwMessageSize: uint32
lpProtocol: pointerstruct PROTOCOL_INFOA
{
uint dwServiceFlags;
int iAddressFamily;
int iMaxSockAddr;
int iMinSockAddr;
int iSocketType;
int iProtocol;
uint dwMessageSize;
void* lpProtocol;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; PROTOCOL_INFOA サイズ: 32 バイト(x86)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; dwServiceFlags : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; iAddressFamily : INT (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; iMaxSockAddr : INT (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; iMinSockAddr : INT (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; iSocketType : INT (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; iProtocol : INT (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; dwMessageSize : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; lpProtocol : LPSTR (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; PROTOCOL_INFOA サイズ: 40 バイト(x64)
dim st, 10 ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; dwServiceFlags : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; iAddressFamily : INT (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; iMaxSockAddr : INT (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; iMinSockAddr : INT (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; iSocketType : INT (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; iProtocol : INT (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; dwMessageSize : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; lpProtocol : LPSTR (+32, 8byte) qpoke st,32,値 / qpeek(st,32) ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global PROTOCOL_INFOA
#field int dwServiceFlags
#field int iAddressFamily
#field int iMaxSockAddr
#field int iMinSockAddr
#field int iSocketType
#field int iProtocol
#field int dwMessageSize
#field intptr lpProtocol
#endstruct
stdim st, PROTOCOL_INFOA ; NSTRUCT 変数を確保
st->dwServiceFlags = 100
mes "dwServiceFlags=" + st->dwServiceFlags