ホーム › Networking.WinSock › WSAPOLLDATA
WSAPOLLDATA
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| result | INT | 4 | +0 | +0 | ポーリング結果の戻り値。準備完了したソケット数や負値のエラーを示す。 |
| fds | DWORD | 4 | +4 | +4 | fdArray内に格納されたソケット記述子の数を示す。 |
| timeout | INT | 4 | +8 | +8 | ポーリングのタイムアウトをミリ秒で示す。-1で無限待機。 |
| fdArray | WSAPOLLFD | 16/8 | +16 | +12 | 監視対象のソケットと要求/結果イベントを保持するWSAPOLLFD配列の先頭。 |
各言語での定義
#include <windows.h>
// WSAPOLLFD (x64 16 / x86 8 バイト)
typedef struct WSAPOLLFD {
SOCKET fd;
WSAPOLL_EVENT_FLAGS events;
WSAPOLL_EVENT_FLAGS revents;
} WSAPOLLFD;
// WSAPOLLDATA (x64 32 / x86 20 バイト)
typedef struct WSAPOLLDATA {
INT result;
DWORD fds;
INT timeout;
WSAPOLLFD fdArray[1];
} WSAPOLLDATA;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WSAPOLLFD
{
public UIntPtr fd;
public short events;
public short revents;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WSAPOLLDATA
{
public int result;
public uint fds;
public int timeout;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public WSAPOLLFD[] fdArray;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WSAPOLLFD
Public fd As UIntPtr
Public events As Short
Public revents As Short
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WSAPOLLDATA
Public result As Integer
Public fds As UInteger
Public timeout As Integer
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public fdArray() As WSAPOLLFD
End Structureimport ctypes
from ctypes import wintypes
class WSAPOLLFD(ctypes.Structure):
_fields_ = [
("fd", ctypes.c_size_t),
("events", ctypes.c_short),
("revents", ctypes.c_short),
]
class WSAPOLLDATA(ctypes.Structure):
_fields_ = [
("result", ctypes.c_int),
("fds", wintypes.DWORD),
("timeout", ctypes.c_int),
("fdArray", WSAPOLLFD * 1),
]#[repr(C)]
pub struct WSAPOLLFD {
pub fd: usize,
pub events: i16,
pub revents: i16,
}
#[repr(C)]
pub struct WSAPOLLDATA {
pub result: i32,
pub fds: u32,
pub timeout: i32,
pub fdArray: [WSAPOLLFD; 1],
}import "golang.org/x/sys/windows"
type WSAPOLLFD struct {
fd uintptr
events int16
revents int16
}
type WSAPOLLDATA struct {
result int32
fds uint32
timeout int32
fdArray [1]WSAPOLLFD
}type
WSAPOLLFD = record
fd: NativeUInt;
events: Smallint;
revents: Smallint;
end;
WSAPOLLDATA = record
result: Integer;
fds: DWORD;
timeout: Integer;
fdArray: array[0..0] of WSAPOLLFD;
end;const WSAPOLLFD = extern struct {
fd: usize,
events: i16,
revents: i16,
};
const WSAPOLLDATA = extern struct {
result: i32,
fds: u32,
timeout: i32,
fdArray: [1]WSAPOLLFD,
};type
WSAPOLLFD {.bycopy.} = object
fd: uint
events: int16
revents: int16
WSAPOLLDATA {.bycopy.} = object
result: int32
fds: uint32
timeout: int32
fdArray: array[1, WSAPOLLFD]struct WSAPOLLFD
{
size_t fd;
short events;
short revents;
}
struct WSAPOLLDATA
{
int result;
uint fds;
int timeout;
WSAPOLLFD[1] fdArray;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; WSAPOLLDATA サイズ: 20 バイト(x86)
dim st, 5 ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; result : INT (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; fds : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; timeout : INT (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; fdArray : WSAPOLLFD (+12, 8byte) varptr(st)+12 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WSAPOLLDATA サイズ: 32 バイト(x64)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; result : INT (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; fds : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; timeout : INT (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; fdArray : WSAPOLLFD (+16, 16byte) varptr(st)+16 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global WSAPOLLFD
#field intptr fd
#field short events
#field short revents
#endstruct
#defstruct global WSAPOLLDATA
#field int result
#field int fds
#field int timeout
#field WSAPOLLFD fdArray 1
#endstruct
stdim st, WSAPOLLDATA ; NSTRUCT 変数を確保
st->result = 100
mes "result=" + st->result