ホーム › Networking.WinSock › SOCKADDR_TP
SOCKADDR_TP
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| tp_family | WORD | 2 | +0 | +0 | アドレスファミリを示す。ISO TPではAF_ISO等を設定する。 |
| tp_addr_type | WORD | 2 | +2 | +2 | アドレスの種別を示す。 |
| tp_taddr_len | WORD | 2 | +4 | +4 | tp_addr内のトランスポートアドレス部の長さを示す。 |
| tp_tsel_len | WORD | 2 | +6 | +6 | tp_addr内のトランスポートセレクタ部の長さを示す。 |
| tp_addr | BYTE | 64 | +8 | +8 | トランスポートアドレスとセレクタを連結したバイト列の先頭。 |
各言語での定義
#include <windows.h>
// SOCKADDR_TP (x64 72 / x86 72 バイト)
typedef struct SOCKADDR_TP {
WORD tp_family;
WORD tp_addr_type;
WORD tp_taddr_len;
WORD tp_tsel_len;
BYTE tp_addr[64];
} SOCKADDR_TP;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SOCKADDR_TP
{
public ushort tp_family;
public ushort tp_addr_type;
public ushort tp_taddr_len;
public ushort tp_tsel_len;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] public byte[] tp_addr;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SOCKADDR_TP
Public tp_family As UShort
Public tp_addr_type As UShort
Public tp_taddr_len As UShort
Public tp_tsel_len As UShort
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=64)> Public tp_addr() As Byte
End Structureimport ctypes
from ctypes import wintypes
class SOCKADDR_TP(ctypes.Structure):
_fields_ = [
("tp_family", ctypes.c_ushort),
("tp_addr_type", ctypes.c_ushort),
("tp_taddr_len", ctypes.c_ushort),
("tp_tsel_len", ctypes.c_ushort),
("tp_addr", ctypes.c_ubyte * 64),
]#[repr(C)]
pub struct SOCKADDR_TP {
pub tp_family: u16,
pub tp_addr_type: u16,
pub tp_taddr_len: u16,
pub tp_tsel_len: u16,
pub tp_addr: [u8; 64],
}import "golang.org/x/sys/windows"
type SOCKADDR_TP struct {
tp_family uint16
tp_addr_type uint16
tp_taddr_len uint16
tp_tsel_len uint16
tp_addr [64]byte
}type
SOCKADDR_TP = record
tp_family: Word;
tp_addr_type: Word;
tp_taddr_len: Word;
tp_tsel_len: Word;
tp_addr: array[0..63] of Byte;
end;const SOCKADDR_TP = extern struct {
tp_family: u16,
tp_addr_type: u16,
tp_taddr_len: u16,
tp_tsel_len: u16,
tp_addr: [64]u8,
};type
SOCKADDR_TP {.bycopy.} = object
tp_family: uint16
tp_addr_type: uint16
tp_taddr_len: uint16
tp_tsel_len: uint16
tp_addr: array[64, uint8]struct SOCKADDR_TP
{
ushort tp_family;
ushort tp_addr_type;
ushort tp_taddr_len;
ushort tp_tsel_len;
ubyte[64] tp_addr;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SOCKADDR_TP サイズ: 72 バイト(x64)
dim st, 18 ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; tp_family : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; tp_addr_type : WORD (+2, 2byte) wpoke st,2,値 / 値 = wpeek(st,2)
; tp_taddr_len : WORD (+4, 2byte) wpoke st,4,値 / 値 = wpeek(st,4)
; tp_tsel_len : WORD (+6, 2byte) wpoke st,6,値 / 値 = wpeek(st,6)
; tp_addr : BYTE (+8, 64byte) varptr(st)+8 を基点に操作(64byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SOCKADDR_TP
#field short tp_family
#field short tp_addr_type
#field short tp_taddr_len
#field short tp_tsel_len
#field byte tp_addr 64
#endstruct
stdim st, SOCKADDR_TP ; NSTRUCT 変数を確保
st->tp_family = 100
mes "tp_family=" + st->tp_family