# Module sdl_net

# Imports

sdl

# Types

    PIPAddress = ptr TIPAddress

    TIPAddress = object
      host*: uint32
      port*: uint16

    PTCPSocket = ptr TTCPSocket

    TTCPSocket = object
      ready*: int
      channel*: int
      remoteAddress*: TIPAddress
      localAddress*: TIPAddress
      sflag*: int

    PUDP_Channel = ptr TUDP_Channel

    TUDP_Channel = object
      numbound*: int
      address*: array[0 .. 4 - 1, TIPAddress]

    PUDPSocket = ptr TUDPSocket

    TUDPSocket = object
      ready*: int
      channel*: int
      address*: TIPAddress
      binding*: array[0 .. 32 - 1, TUDP_Channel]

    PUDPpacket = ptr TUDPpacket

    PPUDPpacket = ptr PUDPpacket

    TUDPpacket = object
      channel*: int
      data*: pointer
      length*: int
      maxlen*: int
      status*: int
      address*: TIPAddress

    PSocket = ptr TSocket

    TSocket = object
      ready*: int
      channel*: int

    PSocketSet = ptr TSocketSet

    TSocketSet = object
      numsockets*: int
      maxsockets*: int
      sockets*: PSocket

    PGenericSocket = ptr TGenericSocket

    TGenericSocket = object
      ready*: int

# Consts

    MAJOR_VERSION = 1

    MINOR_VERSION = 2

    PATCHLEVEL = 5

    INADDR_ANY = 0x00000000

    INADDR_NONE = 0xFFFFFFFF

    MAX_UDPCHANNELS = 32

    MAX_UDPADDRESSES = 4

# Procs

    proc Init(): int {.cdecl, importc: "SDLNet_Init", dynlib: NetLibName.}

    proc Quit() {.cdecl, importc: "SDLNet_Quit", dynlib: NetLibName.}

    proc ResolveHost(address: var TIPAddress; host: cstring; port: uint16): int {.
        cdecl, importc: "SDLNet_ResolveHost", dynlib: NetLibName.}

    proc ResolveIP(ip: var TIPAddress): cstring {.cdecl,
        importc: "SDLNet_ResolveIP", dynlib: NetLibName.}

    proc TCP_Open(ip: var TIPAddress): PTCPSocket {.cdecl,
        importc: "SDLNet_TCP_Open", dynlib: NetLibName.}

    proc TCP_Accept(server: PTCPSocket): PTCPSocket {.cdecl,
        importc: "SDLNet_TCP_Accept", dynlib: NetLibName.}

    proc TCP_GetPeerAddress(sock: PTCPSocket): PIPAddress {.cdecl,
        importc: "SDLNet_TCP_GetPeerAddress", dynlib: NetLibName.}

    proc TCP_Send(sock: PTCPSocket; data: pointer; length: int): int {.cdecl,
        importc: "SDLNet_TCP_Send", dynlib: NetLibName.}

    proc TCP_Recv(sock: PTCPSocket; data: pointer; maxlen: int): int {.cdecl,
        importc: "SDLNet_TCP_Recv", dynlib: NetLibName.}

    proc TCP_Close(sock: PTCPSocket) {.cdecl, importc: "SDLNet_TCP_Close",
                                       dynlib: NetLibName.}

    proc AllocPacket(size: int): PUDPpacket {.cdecl, importc: "SDLNet_AllocPacket",
        dynlib: NetLibName.}

    proc ResizePacket(packet: PUDPpacket; newsize: int): int {.cdecl,
        importc: "SDLNet_ResizePacket", dynlib: NetLibName.}

    proc FreePacket(packet: PUDPpacket) {.cdecl, importc: "SDLNet_FreePacket",
                                          dynlib: NetLibName.}

    proc AllocPacketV(howmany: int; size: int): PUDPpacket {.cdecl,
        importc: "SDLNet_AllocPacketV", dynlib: NetLibName.}

    proc FreePacketV(packetV: PUDPpacket) {.cdecl, importc: "SDLNet_FreePacketV",
                                            dynlib: NetLibName.}

    proc UDP_Open(port: uint16): PUDPSocket {.cdecl, importc: "SDLNet_UDP_Open",
        dynlib: NetLibName.}

    proc UDP_Bind(sock: PUDPSocket; channel: int; address: var TIPAddress): int {.
        cdecl, importc: "SDLNet_UDP_Bind", dynlib: NetLibName.}

    proc UDP_Unbind(sock: PUDPSocket; channel: int) {.cdecl,
        importc: "SDLNet_UDP_Unbind", dynlib: NetLibName.}

    proc UDP_GetPeerAddress(sock: PUDPSocket; channel: int): PIPAddress {.cdecl,
        importc: "SDLNet_UDP_GetPeerAddress", dynlib: NetLibName.}

    proc UDP_SendV(sock: PUDPSocket; packets: PPUDPpacket; npackets: int): int {.
        cdecl, importc: "SDLNet_UDP_SendV", dynlib: NetLibName.}

    proc UDP_Send(sock: PUDPSocket; channel: int; packet: PUDPpacket): int {.cdecl,
        importc: "SDLNet_UDP_Send", dynlib: NetLibName.}

    proc UDP_RecvV(sock: PUDPSocket; packets: PPUDPpacket): int {.cdecl,
        importc: "SDLNet_UDP_RecvV", dynlib: NetLibName.}

    proc UDP_Recv(sock: PUDPSocket; packet: PUDPpacket): int {.cdecl,
        importc: "SDLNet_UDP_Recv", dynlib: NetLibName.}

    proc UDP_Close(sock: PUDPSocket) {.cdecl, importc: "SDLNet_UDP_Close",
                                       dynlib: NetLibName.}

    proc AllocSocketSet(maxsockets: int): PSocketSet {.cdecl,
        importc: "SDLNet_AllocSocketSet", dynlib: NetLibName.}

    proc AddSocket(theSet: PSocketSet; sock: PGenericSocket): int {.cdecl,
        importc: "SDLNet_AddSocket", dynlib: NetLibName.}

    proc DelSocket(theSet: PSocketSet; sock: PGenericSocket): int {.cdecl,
        importc: "SDLNet_DelSocket", dynlib: NetLibName.}

    proc CheckSockets(theSet: PSocketSet; timeout: int32): int {.cdecl,
        importc: "SDLNet_CheckSockets", dynlib: NetLibName.}

    proc FreeSocketSet(theSet: PSocketSet) {.cdecl, importc: "SDLNet_FreeSocketSet",
        dynlib: NetLibName.}

    proc Write16(value: uint16; area: pointer) {.cdecl, importc: "SDLNet_Write16",
        dynlib: NetLibName.}

    proc Write32(value: uint32; area: pointer) {.cdecl, importc: "SDLNet_Write32",
        dynlib: NetLibName.}

    proc Read16(area: pointer): uint16 {.cdecl, importc: "SDLNet_Read16",
                                         dynlib: NetLibName.}

    proc Read32(area: pointer): uint32 {.cdecl, importc: "SDLNet_Read32",
                                         dynlib: NetLibName.}

    proc VERSION(X: var Tversion) {.raises: [], tags: [].}

    proc TCP_AddSocket(theSet: PSocketSet; sock: PTCPSocket): int {.raises: [],
        tags: [].}

    proc UDP_AddSocket(theSet: PSocketSet; sock: PUDPSocket): int {.raises: [],
        tags: [].}

    proc TCP_DelSocket(theSet: PSocketSet; sock: PTCPSocket): int {.raises: [],
        tags: [].}

    proc UDP_DelSocket(theSet: PSocketSet; sock: PUDPSocket): int {.raises: [],
        tags: [].}

    proc SocketReady(sock: PGenericSocket): bool {.raises: [], tags: [].}

Generated: 2013-05-21 09:55:05 UTC