ホーム › Networking.WinSock › shutdown
shutdown
関数ソケットの送受信を部分的または全面的に停止する。
シグネチャ
// WS2_32.dll
#include <windows.h>
INT shutdown(
SOCKET s,
WINSOCK_SHUTDOWN_HOW how
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| s | SOCKET | in |
| how | WINSOCK_SHUTDOWN_HOW | in |
戻り値の型: INT
各言語での呼び出し定義
// WS2_32.dll
#include <windows.h>
INT shutdown(
SOCKET s,
WINSOCK_SHUTDOWN_HOW how
);[DllImport("WS2_32.dll", SetLastError = true, ExactSpelling = true)]
static extern int shutdown(
UIntPtr s, // SOCKET
int how // WINSOCK_SHUTDOWN_HOW
);<DllImport("WS2_32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function shutdown(
s As UIntPtr, ' SOCKET
how As Integer ' WINSOCK_SHUTDOWN_HOW
) As Integer
End Function' s : SOCKET
' how : WINSOCK_SHUTDOWN_HOW
Declare PtrSafe Function shutdown Lib "ws2_32" ( _
ByVal s As LongPtr, _
ByVal how As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
shutdown = ctypes.windll.ws2_32.shutdown
shutdown.restype = ctypes.c_int
shutdown.argtypes = [
ctypes.c_size_t, # s : SOCKET
ctypes.c_int, # how : WINSOCK_SHUTDOWN_HOW
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WS2_32.dll')
shutdown = Fiddle::Function.new(
lib['shutdown'],
[
Fiddle::TYPE_UINTPTR_T, # s : SOCKET
Fiddle::TYPE_INT, # how : WINSOCK_SHUTDOWN_HOW
],
Fiddle::TYPE_INT)#[link(name = "ws2_32")]
extern "system" {
fn shutdown(
s: usize, // SOCKET
how: i32 // WINSOCK_SHUTDOWN_HOW
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WS2_32.dll", SetLastError = true)]
public static extern int shutdown(UIntPtr s, int how);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WS2_32_shutdown' -Namespace Win32 -PassThru
# $api::shutdown(s, how)#uselib "WS2_32.dll"
#func global shutdown "shutdown" sptr, sptr
; shutdown s, how ; 戻り値は stat
; s : SOCKET -> "sptr"
; how : WINSOCK_SHUTDOWN_HOW -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "WS2_32.dll"
#cfunc global shutdown "shutdown" sptr, int
; res = shutdown(s, how)
; s : SOCKET -> "sptr"
; how : WINSOCK_SHUTDOWN_HOW -> "int"; INT shutdown(SOCKET s, WINSOCK_SHUTDOWN_HOW how)
#uselib "WS2_32.dll"
#cfunc global shutdown "shutdown" intptr, int
; res = shutdown(s, how)
; s : SOCKET -> "intptr"
; how : WINSOCK_SHUTDOWN_HOW -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ws2_32 = windows.NewLazySystemDLL("WS2_32.dll")
procshutdown = ws2_32.NewProc("shutdown")
)
// s (SOCKET), how (WINSOCK_SHUTDOWN_HOW)
r1, _, err := procshutdown.Call(
uintptr(s),
uintptr(how),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction shutdown(
s: NativeUInt; // SOCKET
how: Integer // WINSOCK_SHUTDOWN_HOW
): Integer; stdcall;
external 'WS2_32.dll' name 'shutdown';result := DllCall("WS2_32\shutdown"
, "UPtr", s ; SOCKET
, "Int", how ; WINSOCK_SHUTDOWN_HOW
, "Int") ; return: INT●shutdown(s, how) = DLL("WS2_32.dll", "int shutdown(int, int)")
# 呼び出し: shutdown(s, how)
# s : SOCKET -> "int"
# how : WINSOCK_SHUTDOWN_HOW -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。