Win32 API 日本語リファレンス
ホームNetworking.WinSock › select

select

関数
複数ソケットの入出力可否を監視する。
DLLWS2_32.dll呼出規約winapiSetLastErrorあり対応OSWindows 8.1 以降

シグネチャ

// WS2_32.dll
#include <windows.h>

INT select(
    INT nfds,
    FD_SET* readfds,   // optional
    FD_SET* writefds,   // optional
    FD_SET* exceptfds,   // optional
    const TIMEVAL* timeout   // optional
);

パラメーター

名前方向説明
nfdsINTin無視されます。nfds パラメーターは、Berkeley ソケットとの互換性のためにのみ含まれています。
readfdsFD_SET*inoutoptional読み取り可能かどうかを確認するソケットのセットへの省略可能なポインター。
writefdsFD_SET*inoutoptional書き込み可能かどうかを確認するソケットのセットへの省略可能なポインター。
exceptfdsFD_SET*inoutoptionalエラーの有無を確認するソケットのセットへの省略可能なポインター。
timeoutTIMEVAL*inoptionalselect が待機する最大時間。 TIMEVAL 構造体の形式で指定します。ブロッキング操作の場合は、timeout パラメーターを null に設定します。

戻り値の型: INT

公式ドキュメント

select 関数は、1 つ以上のソケットの状態を判定し、同期 I/O を実行するために必要に応じて待機します。

戻り値

select 関数は、準備が完了し fd_set 構造体に含まれるソケットハンドルの総数を返します。制限時間が経過した場合は 0 を、エラーが発生した場合は SOCKET_ERROR を返します。戻り値が SOCKET_ERROR の場合は、 WSAGetLastError を使用して特定のエラーコードを取得できます。

エラーコード 意味
WSANOTINITIALISED
この関数を使用する前に、 WSAStartup の呼び出しが成功している必要があります。
WSAEFAULT
Windows Sockets 実装が内部操作に必要なリソースを割り当てられなかったか、readfdswritefdsexceptfds、または timeval パラメーターがユーザーアドレス空間の一部ではありません。
WSAENETDOWN
ネットワークサブシステムが失敗しました。
WSAEINVAL
time-out 値が無効な場合、または 3 つの記述子パラメーターすべてが null ポインターであるか、ソケットを含まない空の fd_set 構造体への有効なポインターである場合に、WSAEINVAL が返されます。
WSAEINTR
ブロッキング中の Windows Socket 1.1 呼び出しが WSACancelBlockingCall によってキャンセルされました。
WSAEINPROGRESS
ブロッキング中の Windows Sockets 1.1 呼び出しが進行中であるか、サービスプロバイダーがコールバック関数を処理中です。
WSAENOTSOCK
記述子セットのいずれかに、ソケットではないエントリが含まれています。

解説(Remarks)

select 関数は、1 つ以上のソケットの状態を判定するために使用します。各ソケットについて、呼び出し側は読み取り、書き込み、またはエラーの状態に関する情報を要求できます。特定の状態を要求するソケットのセットは、 fd_set 構造体によって指定します。 fd_set 構造体に含まれるソケットは、単一のサービスプロバイダーに関連付けられている必要があります。この制限上、各ソケットのプロトコルを記述する WSAPROTOCOL_INFO 構造体の providerId 値が同じであれば、それらのソケットは同じサービスプロバイダーに属すると見なされます。戻り時には、これらの構造体は、指定された条件を満たすソケットのサブセットを反映するように更新されます。 select 関数は、条件を満たすソケットの数を返します。 fd_set 構造体を操作するための一連のマクロが用意されています。これらのマクロは Berkeley ソフトウェアで使用されているものと互換性がありますが、内部表現は完全に異なります。

readfds パラメーターは、読み取り可能かどうかを確認するソケットを指定します。ソケットが現在 listen 状態にある場合、着信接続要求を受信して accept がブロックせずに完了することが保証されているときに、読み取り可能としてマークされます。その他のソケットの場合、読み取り可能とは、 recvWSARecvWSARecvFrom、または recvfrom の呼び出しがブロックしないことが保証される程度に、キューに格納されたデータが読み取り可能であることを意味します。

コネクション指向のソケットの場合、読み取り可能であることは、ソケットを閉じる要求がピアから受信されたことを示す場合もあります。仮想回線が正常に閉じられ、すべてのデータが受信された場合、 recv は読み取りバイト数 0 で直ちに返ります。仮想回線がリセットされた場合、 recvWSAECONNRESET などのエラーコードを伴って直ちに完了します。ソケットオプション SO_OOBINLINE が有効になっている場合は、OOB データの有無も確認されます ( setsockopt を参照)。

writefds パラメーターは、書き込み可能かどうかを確認するソケットを指定します。ソケットが connect 呼び出し (非ブロッキング) を処理中の場合、接続の確立が正常に完了するとソケットは書き込み可能になります。ソケットが connect 呼び出しを処理していない場合、書き込み可能とは、 sendsendto、または WSASendto が成功することが保証されることを意味します。ただし、len パラメーターが利用可能な送信システムバッファー空間の容量を超える場合、ブロッキングソケットではブロックする可能性があります。これらの保証がどれくらいの期間有効であると想定できるかは、特にマルチスレッド環境では規定されていません。

exceptfds パラメーターは、OOB データの有無や例外的なエラー状態を確認するソケットを指定します。

アウトオブバンドデータがこの方法で報告されるのは、オプション SO_OOBINLINEFALSE の場合のみです。ソケットが connect 呼び出し (非ブロッキング) を処理中の場合、接続試行の失敗は exceptfds に示されます (この場合、アプリケーションは getsockopt SO_ERROR を呼び出して、失敗の原因を表すエラー値を判定する必要があります)。このドキュメントでは、含まれるその他のエラーについては定義していません。
readfdswritefdsexceptfds のうち任意の 2 つを null として指定できます。少なくとも 1 つは非 null でなければならず、非 null の記述子セットには少なくとも 1 つのソケットへのハンドルが含まれている必要があります。

まとめると、 select が返るときに、ソケットが特定のセット内で識別されるのは次の場合です。

readfds:

writefds: exceptfds: 記述子セットを操作および確認するために、ヘッダーファイル Winsock2.h で 4 つのマクロが定義されています。変数 FD_SETSIZE は、セット内の記述子の最大数を決定します。(FD_SETSIZE の既定値は 64 で、Winsock2.h をインクルードする前に FD_SETSIZE を別の値で定義することで変更できます。) 内部的には、 fd_set 構造体内のソケットハンドルは、Berkeley Unix のようにビットフラグとしては表現されません。そのデータ表現は不透明です。これらのマクロを使用することで、異なるソケット環境間でのソフトウェアの移植性が維持されます。 fd_set の内容を操作および確認するマクロは次のとおりです。

time-out パラメーターは、 select が完了するまでにかかる時間を制御します。time-outnull ポインターの場合、 select は少なくとも 1 つの記述子が指定された条件を満たすまで無期限にブロックします。それ以外の場合、time-outTIMEVAL 構造体を指し、 select が返るまでに待機する最大時間を指定します。 select が返るとき、TIMEVAL 構造体の内容は変更されません。TIMEVAL が {0, 0} に初期化されている場合、 select は直ちに返ります。これは、選択したソケットの状態をポーリングするために使用されます。 select が直ちに返る場合、その select 呼び出しは非ブロッキングと見なされ、非ブロッキング呼び出しに関する標準的な前提が適用されます。たとえば、ブロッキングフックは呼び出されず、Windows Sockets は処理を譲りません。

select 関数は、 WSAAsyncSelect または WSAEventSelect で登録されたソケットイベントの永続性には影響しません。
timeout パラメーターを NULL に設定して select などのブロッキング Winsock 呼び出しを発行する場合、呼び出しが完了する前に Winsock がネットワークイベントを待機する必要が生じることがあります。この状況では Winsock はアラート可能な待機を実行し、これは同じスレッドでスケジュールされた非同期プロシージャ呼び出し (APC) によって中断される可能性があります。同じスレッドで進行中のブロッキング Winsock 呼び出しを中断した APC の内部で別のブロッキング Winsock 呼び出しを発行すると、未定義の動作につながるため、Winsock クライアントは決して行ってはなりません。
Windows Phone 8: この関数は、Windows Phone 8 以降の Windows Phone ストアアプリでサポートされています。

Windows 8.1 および Windows Server 2012 R2: この関数は、Windows 8.1、Windows Server 2012 R2 以降の Windows ストアアプリでサポートされています。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// WS2_32.dll
#include <windows.h>

INT select(
    INT nfds,
    FD_SET* readfds,   // optional
    FD_SET* writefds,   // optional
    FD_SET* exceptfds,   // optional
    const TIMEVAL* timeout   // optional
);
[DllImport("WS2_32.dll", SetLastError = true, ExactSpelling = true)]
static extern int select(
    int nfds,   // INT
    IntPtr readfds,   // FD_SET* optional, in/out
    IntPtr writefds,   // FD_SET* optional, in/out
    IntPtr exceptfds,   // FD_SET* optional, in/out
    IntPtr timeout   // TIMEVAL* optional
);
<DllImport("WS2_32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function select(
    nfds As Integer,   ' INT
    readfds As IntPtr,   ' FD_SET* optional, in/out
    writefds As IntPtr,   ' FD_SET* optional, in/out
    exceptfds As IntPtr,   ' FD_SET* optional, in/out
    timeout As IntPtr   ' TIMEVAL* optional
) As Integer
End Function
' nfds : INT
' readfds : FD_SET* optional, in/out
' writefds : FD_SET* optional, in/out
' exceptfds : FD_SET* optional, in/out
' timeout : TIMEVAL* optional
Declare PtrSafe Function select Lib "ws2_32" ( _
    ByVal nfds As Long, _
    ByVal readfds As LongPtr, _
    ByVal writefds As LongPtr, _
    ByVal exceptfds As LongPtr, _
    ByVal timeout As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

select = ctypes.windll.ws2_32.select
select.restype = ctypes.c_int
select.argtypes = [
    ctypes.c_int,  # nfds : INT
    ctypes.c_void_p,  # readfds : FD_SET* optional, in/out
    ctypes.c_void_p,  # writefds : FD_SET* optional, in/out
    ctypes.c_void_p,  # exceptfds : FD_SET* optional, in/out
    ctypes.c_void_p,  # timeout : TIMEVAL* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WS2_32.dll')
select = Fiddle::Function.new(
  lib['select'],
  [
    Fiddle::TYPE_INT,  # nfds : INT
    Fiddle::TYPE_VOIDP,  # readfds : FD_SET* optional, in/out
    Fiddle::TYPE_VOIDP,  # writefds : FD_SET* optional, in/out
    Fiddle::TYPE_VOIDP,  # exceptfds : FD_SET* optional, in/out
    Fiddle::TYPE_VOIDP,  # timeout : TIMEVAL* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "ws2_32")]
extern "system" {
    fn select(
        nfds: i32,  // INT
        readfds: *mut FD_SET,  // FD_SET* optional, in/out
        writefds: *mut FD_SET,  // FD_SET* optional, in/out
        exceptfds: *mut FD_SET,  // FD_SET* optional, in/out
        timeout: *const TIMEVAL  // TIMEVAL* optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WS2_32.dll", SetLastError = true)]
public static extern int select(int nfds, IntPtr readfds, IntPtr writefds, IntPtr exceptfds, IntPtr timeout);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WS2_32_select' -Namespace Win32 -PassThru
# $api::select(nfds, readfds, writefds, exceptfds, timeout)
#uselib "WS2_32.dll"
#func global select "select" sptr, sptr, sptr, sptr, sptr
; select nfds, varptr(readfds), varptr(writefds), varptr(exceptfds), varptr(timeout)   ; 戻り値は stat
; nfds : INT -> "sptr"
; readfds : FD_SET* optional, in/out -> "sptr"
; writefds : FD_SET* optional, in/out -> "sptr"
; exceptfds : FD_SET* optional, in/out -> "sptr"
; timeout : TIMEVAL* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WS2_32.dll"
#cfunc global select "select" int, var, var, var, var
; res = select(nfds, readfds, writefds, exceptfds, timeout)
; nfds : INT -> "int"
; readfds : FD_SET* optional, in/out -> "var"
; writefds : FD_SET* optional, in/out -> "var"
; exceptfds : FD_SET* optional, in/out -> "var"
; timeout : TIMEVAL* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT select(INT nfds, FD_SET* readfds, FD_SET* writefds, FD_SET* exceptfds, TIMEVAL* timeout)
#uselib "WS2_32.dll"
#cfunc global select "select" int, var, var, var, var
; res = select(nfds, readfds, writefds, exceptfds, timeout)
; nfds : INT -> "int"
; readfds : FD_SET* optional, in/out -> "var"
; writefds : FD_SET* optional, in/out -> "var"
; exceptfds : FD_SET* optional, in/out -> "var"
; timeout : TIMEVAL* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ws2_32 = windows.NewLazySystemDLL("WS2_32.dll")
	procselect = ws2_32.NewProc("select")
)

// nfds (INT), readfds (FD_SET* optional, in/out), writefds (FD_SET* optional, in/out), exceptfds (FD_SET* optional, in/out), timeout (TIMEVAL* optional)
r1, _, err := procselect.Call(
	uintptr(nfds),
	uintptr(readfds),
	uintptr(writefds),
	uintptr(exceptfds),
	uintptr(timeout),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function select(
  nfds: Integer;   // INT
  readfds: Pointer;   // FD_SET* optional, in/out
  writefds: Pointer;   // FD_SET* optional, in/out
  exceptfds: Pointer;   // FD_SET* optional, in/out
  timeout: Pointer   // TIMEVAL* optional
): Integer; stdcall;
  external 'WS2_32.dll' name 'select';
result := DllCall("WS2_32\select"
    , "Int", nfds   ; INT
    , "Ptr", readfds   ; FD_SET* optional, in/out
    , "Ptr", writefds   ; FD_SET* optional, in/out
    , "Ptr", exceptfds   ; FD_SET* optional, in/out
    , "Ptr", timeout   ; TIMEVAL* optional
    , "Int")   ; return: INT
●select(nfds, readfds, writefds, exceptfds, timeout) = DLL("WS2_32.dll", "int select(int, void*, void*, void*, void*)")
# 呼び出し: select(nfds, readfds, writefds, exceptfds, timeout)
# nfds : INT -> "int"
# readfds : FD_SET* optional, in/out -> "void*"
# writefds : FD_SET* optional, in/out -> "void*"
# exceptfds : FD_SET* optional, in/out -> "void*"
# timeout : TIMEVAL* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "ws2_32" fn select(
    nfds: i32, // INT
    readfds: [*c]FD_SET, // FD_SET* optional, in/out
    writefds: [*c]FD_SET, // FD_SET* optional, in/out
    exceptfds: [*c]FD_SET, // FD_SET* optional, in/out
    timeout: [*c]TIMEVAL // TIMEVAL* optional
) callconv(std.os.windows.WINAPI) i32;
proc select(
    nfds: int32,  # INT
    readfds: ptr FD_SET,  # FD_SET* optional, in/out
    writefds: ptr FD_SET,  # FD_SET* optional, in/out
    exceptfds: ptr FD_SET,  # FD_SET* optional, in/out
    timeout: ptr TIMEVAL  # TIMEVAL* optional
): int32 {.importc: "select", stdcall, dynlib: "WS2_32.dll".}
pragma(lib, "ws2_32");
extern(Windows)
int select(
    int nfds,   // INT
    FD_SET* readfds,   // FD_SET* optional, in/out
    FD_SET* writefds,   // FD_SET* optional, in/out
    FD_SET* exceptfds,   // FD_SET* optional, in/out
    TIMEVAL* timeout   // TIMEVAL* optional
);
ccall((:select, "WS2_32.dll"), stdcall, Int32,
      (Int32, Ptr{FD_SET}, Ptr{FD_SET}, Ptr{FD_SET}, Ptr{TIMEVAL}),
      nfds, readfds, writefds, exceptfds, timeout)
# nfds : INT -> Int32
# readfds : FD_SET* optional, in/out -> Ptr{FD_SET}
# writefds : FD_SET* optional, in/out -> Ptr{FD_SET}
# exceptfds : FD_SET* optional, in/out -> Ptr{FD_SET}
# timeout : TIMEVAL* optional -> Ptr{TIMEVAL}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t select(
    int32_t nfds,
    void* readfds,
    void* writefds,
    void* exceptfds,
    void* timeout);
]]
local ws2_32 = ffi.load("ws2_32")
-- ws2_32.select(nfds, readfds, writefds, exceptfds, timeout)
-- nfds : INT
-- readfds : FD_SET* optional, in/out
-- writefds : FD_SET* optional, in/out
-- exceptfds : FD_SET* optional, in/out
-- timeout : TIMEVAL* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WS2_32.dll');
const select = lib.func('__stdcall', 'select', 'int32_t', ['int32_t', 'void *', 'void *', 'void *', 'void *']);
// select(nfds, readfds, writefds, exceptfds, timeout)
// nfds : INT -> 'int32_t'
// readfds : FD_SET* optional, in/out -> 'void *'
// writefds : FD_SET* optional, in/out -> 'void *'
// exceptfds : FD_SET* optional, in/out -> 'void *'
// timeout : TIMEVAL* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WS2_32.dll", {
  select: { parameters: ["i32", "pointer", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.select(nfds, readfds, writefds, exceptfds, timeout)
// nfds : INT -> "i32"
// readfds : FD_SET* optional, in/out -> "pointer"
// writefds : FD_SET* optional, in/out -> "pointer"
// exceptfds : FD_SET* optional, in/out -> "pointer"
// timeout : TIMEVAL* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t select(
    int32_t nfds,
    void* readfds,
    void* writefds,
    void* exceptfds,
    void* timeout);
C, "WS2_32.dll");
// $ffi->select(nfds, readfds, writefds, exceptfds, timeout);
// nfds : INT
// readfds : FD_SET* optional, in/out
// writefds : FD_SET* optional, in/out
// exceptfds : FD_SET* optional, in/out
// timeout : TIMEVAL* optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Ws2_32 extends StdCallLibrary {
    Ws2_32 INSTANCE = Native.load("ws2_32", Ws2_32.class);
    int select(
        int nfds,   // INT
        Pointer readfds,   // FD_SET* optional, in/out
        Pointer writefds,   // FD_SET* optional, in/out
        Pointer exceptfds,   // FD_SET* optional, in/out
        Pointer timeout   // TIMEVAL* optional
    );
}
@[Link("ws2_32")]
lib LibWS2_32
  fun select = select(
    nfds : Int32,   # INT
    readfds : FD_SET*,   # FD_SET* optional, in/out
    writefds : FD_SET*,   # FD_SET* optional, in/out
    exceptfds : FD_SET*,   # FD_SET* optional, in/out
    timeout : TIMEVAL*   # TIMEVAL* optional
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef selectNative = Int32 Function(Int32, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef selectDart = int Function(int, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
final select = DynamicLibrary.open('WS2_32.dll')
    .lookupFunction<selectNative, selectDart>('select');
// nfds : INT -> Int32
// readfds : FD_SET* optional, in/out -> Pointer<Void>
// writefds : FD_SET* optional, in/out -> Pointer<Void>
// exceptfds : FD_SET* optional, in/out -> Pointer<Void>
// timeout : TIMEVAL* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function select(
  nfds: Integer;   // INT
  readfds: Pointer;   // FD_SET* optional, in/out
  writefds: Pointer;   // FD_SET* optional, in/out
  exceptfds: Pointer;   // FD_SET* optional, in/out
  timeout: Pointer   // TIMEVAL* optional
): Integer; stdcall;
  external 'WS2_32.dll' name 'select';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "select"
  c_select :: Int32 -> Ptr () -> Ptr () -> Ptr () -> Ptr () -> IO Int32
-- nfds : INT -> Int32
-- readfds : FD_SET* optional, in/out -> Ptr ()
-- writefds : FD_SET* optional, in/out -> Ptr ()
-- exceptfds : FD_SET* optional, in/out -> Ptr ()
-- timeout : TIMEVAL* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let select =
  foreign "select"
    (int32_t @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* nfds : INT -> int32_t *)
(* readfds : FD_SET* optional, in/out -> (ptr void) *)
(* writefds : FD_SET* optional, in/out -> (ptr void) *)
(* exceptfds : FD_SET* optional, in/out -> (ptr void) *)
(* timeout : TIMEVAL* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library ws2_32 (t "WS2_32.dll"))
(cffi:use-foreign-library ws2_32)

(cffi:defcfun ("select" select :convention :stdcall) :int32
  (nfds :int32)   ; INT
  (readfds :pointer)   ; FD_SET* optional, in/out
  (writefds :pointer)   ; FD_SET* optional, in/out
  (exceptfds :pointer)   ; FD_SET* optional, in/out
  (timeout :pointer))   ; TIMEVAL* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $select = Win32::API::More->new('WS2_32',
    'int select(int nfds, LPVOID readfds, LPVOID writefds, LPVOID exceptfds, LPVOID timeout)');
# my $ret = $select->Call($nfds, $readfds, $writefds, $exceptfds, $timeout);
# nfds : INT -> int
# readfds : FD_SET* optional, in/out -> LPVOID
# writefds : FD_SET* optional, in/out -> LPVOID
# exceptfds : FD_SET* optional, in/out -> LPVOID
# timeout : TIMEVAL* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目
使用する型