main
Raw Download raw file
 1package socket
 2
 3import (
 4	"unsafe"
 5)
 6
 7// RawSockaddr allows structs to be used with [Bind] and [ConnectEx]. The
 8// struct must meet the Win32 sockaddr requirements specified here:
 9// https://docs.microsoft.com/en-us/windows/win32/winsock/sockaddr-2
10//
11// Specifically, the struct size must be least larger than an int16 (unsigned short)
12// for the address family.
13type RawSockaddr interface {
14	// Sockaddr returns a pointer to the RawSockaddr and its struct size, allowing
15	// for the RawSockaddr's data to be overwritten by syscalls (if necessary).
16	//
17	// It is the callers responsibility to validate that the values are valid; invalid
18	// pointers or size can cause a panic.
19	Sockaddr() (unsafe.Pointer, int32, error)
20}