"""
Auto-generated Python stub file from w32.winsock2.py
Module: w32.winsock2
"""


import t, c
from stdint import *
from w32.win32base import *

WINSOCK_VERSION: t.CDefine = 0x0202  # 2.2
AF_INET: t.CDefine = 2
AF_INET6: t.CDefine = 23
SOCK_STREAM: t.CDefine = 1     # TCP
SOCK_DGRAM: t.CDefine = 2      # UDP
SOCK_RAW: t.CDefine = 3        # 原始套接字
IPPROTO_TCP: t.CDefine = 6
IPPROTO_UDP: t.CDefine = 17
SOL_SOCKET: t.CDefine = 0xFFFF      # WinSock2 值
SO_RCVTIMEO: t.CDefine = 0x1006     # WinSock2 值
SO_SNDTIMEO: t.CDefine = 0x1005     # WinSock2 值
SO_REUSEADDR: t.CDefine = 0x0004    # WinSock2 值
INADDR_ANY: t.CDefine = 0
SOCKET_ERROR: t.CDefine = -1
INVALID_SOCKET: t.CDefine = 0xFFFFFFFF  # WinSock2: ~0
MSG_NOSIGNAL: t.CDefine = 0  # Windows 不支持，设为 0
SD_SEND: t.CDefine = 1
SD_RECV: t.CDefine = 0
SD_BOTH: t.CDefine = 2

class WSASocketAddr:
    family: u16
    port: u16
    addr: u32
    zero: u64
class WSAData:
    wVersion: WORD
    wHighVersion: WORD
    szDescription: BYTE
    szSystemStatus: BYTE
    iMaxSockets: u16
    iMaxUdpDg: u16
    lpVendorInfo: CHARPTR
class WSAHostEnt:
    h_name: CHARPTR
    h_aliases: CHARPTR
    h_addrtype: SHORT
    h_length: SHORT
    h_addr_list: CHARPTR
class WinTimeVal:
    tv_sec: LONG
    tv_usec: LONG

def WSAStartup(wVersionRequested: WORD, lpWSAData: WSAData | t.CPtr) -> INT | t.State: pass

def WSACleanup() -> INT | t.State: pass

def WSAGetLastError() -> INT | t.State: pass

def socket(family: INT, type: INT, protocol: INT) -> u64 | t.State: pass

def closesocket(s: u64) -> INT | t.State: pass

def connect(s: u64, name: WSASocketAddr | t.CPtr, namelen: INT) -> INT | t.State: pass

def send(s: u64, buf: t.CVoid | t.CPtr, len: INT, flags: INT) -> INT | t.State: pass

def recv(s: u64, buf: t.CVoid | t.CPtr, len: INT, flags: INT) -> INT | t.State: pass

def bind(s: u64, name: WSASocketAddr | t.CPtr, namelen: INT) -> INT | t.State: pass

def listen(s: u64, backlog: INT) -> INT | t.State: pass

def accept(s: u64, addr: WSASocketAddr | t.CPtr, addrlen: INT | t.CPtr) -> u64 | t.State: pass

def setsockopt(s: u64, level: INT, optname: INT, optval: t.CVoid | t.CPtr, optlen: INT) -> INT | t.State: pass

def shutdown(s: u64, how: INT) -> INT | t.State: pass

def gethostbyname(name: t.CChar | t.CConst | t.CPtr) -> WSAHostEnt | t.CPtr | t.State: pass

def ntohs(netshort: u16) -> u16 | t.State: pass

def htons(hostshort: u16) -> u16 | t.State: pass

def inet_addr(cp: t.CChar | t.CConst | t.CPtr) -> u32 | t.State: pass
