ホーム › Networking.WinSock › WSAPOLLFD
WSAPOLLFD
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| fd | SOCKET | 8/4 | +0 | +0 | ポーリング対象のソケットである。負値の場合は無視される。 |
| events | WSAPOLL_EVENT_FLAGS | 2 | +8 | +4 | 監視を要求するイベントのビットマスクである。POLLRDNORM等。 |
| revents | WSAPOLL_EVENT_FLAGS | 2 | +10 | +6 | 実際に発生したイベントを示す出力ビットマスクである。 |
各言語での定義
#include <windows.h>
// WSAPOLLFD (x64 16 / x86 8 バイト)
typedef struct WSAPOLLFD {
SOCKET fd;
WSAPOLL_EVENT_FLAGS events;
WSAPOLL_EVENT_FLAGS revents;
} WSAPOLLFD;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WSAPOLLFD
{
public UIntPtr fd;
public short events;
public short revents;
}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 Structureimport ctypes
from ctypes import wintypes
class WSAPOLLFD(ctypes.Structure):
_fields_ = [
("fd", ctypes.c_size_t),
("events", ctypes.c_short),
("revents", ctypes.c_short),
]#[repr(C)]
pub struct WSAPOLLFD {
pub fd: usize,
pub events: i16,
pub revents: i16,
}import "golang.org/x/sys/windows"
type WSAPOLLFD struct {
fd uintptr
events int16
revents int16
}type
WSAPOLLFD = record
fd: NativeUInt;
events: Smallint;
revents: Smallint;
end;const WSAPOLLFD = extern struct {
fd: usize,
events: i16,
revents: i16,
};type
WSAPOLLFD {.bycopy.} = object
fd: uint
events: int16
revents: int16struct WSAPOLLFD
{
size_t fd;
short events;
short revents;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; WSAPOLLFD サイズ: 8 バイト(x86)
dim st, 2 ; 4byte整数×2(構造体サイズ 8 / 4 切り上げ)
; fd : SOCKET (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; events : WSAPOLL_EVENT_FLAGS (+4, 2byte) wpoke st,4,値 / 値 = wpeek(st,4)
; revents : WSAPOLL_EVENT_FLAGS (+6, 2byte) wpoke st,6,値 / 値 = wpeek(st,6)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WSAPOLLFD サイズ: 16 バイト(x64)
dim st, 4 ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; fd : SOCKET (+0, 8byte) qpoke st,0,値 / qpeek(st,0) ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; events : WSAPOLL_EVENT_FLAGS (+8, 2byte) wpoke st,8,値 / 値 = wpeek(st,8)
; revents : WSAPOLL_EVENT_FLAGS (+10, 2byte) wpoke st,10,値 / 値 = wpeek(st,10)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global WSAPOLLFD
#field intptr fd
#field short events
#field short revents
#endstruct
stdim st, WSAPOLLFD ; NSTRUCT 変数を確保
st->fd = 100
mes "fd=" + st->fd