' net_constants.pb — Network protocol constants simulation
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL socketType AS LONG
    LOCAL protocolFamily AS LONG
    LOCAL addressFamily AS LONG
    LOCAL sockOpt AS LONG
    LOCAL ipProto AS LONG
    LOCAL tcpState AS LONG
    LOCAL httpMethod AS LONG
    LOCAL httpStatus AS LONG
    LOCAL dnsRecordType AS LONG
    LOCAL i AS LONG
    LOCAL j AS LONG
    LOCAL totalItems AS LONG
    LOCAL protoStr AS STRING
    LOCAL methodStr AS STRING
    LOCAL statusStr AS STRING
    LOCAL dnsStr AS STRING
    LOCAL iter AS LONG
    LOCAL numItems AS LONG
    LOCAL itemID AS LONG
    LOCAL result AS LONG

    numItems = 18

    PRINT "=== Network Constants ==="

    FOR totalItems = 1 TO numItems
        itemID = totalItems

        IF itemID = 1 THEN socketType = 1
        IF itemID = 2 THEN socketType = 2
        IF itemID = 3 THEN socketType = 3
        IF itemID = 4 THEN socketType = 4

        IF itemID = 1 THEN protocolFamily = 2
        IF itemID = 2 THEN protocolFamily = 2
        IF itemID = 3 THEN protocolFamily = 2
        IF itemID = 4 THEN protocolFamily = 2

        IF itemID = 5 THEN ipProto = 1
        IF itemID = 6 THEN ipProto = 6
        IF itemID = 7 THEN ipProto = 17
        IF itemID = 8 THEN ipProto = 2

        IF itemID = 5 THEN PRINT "  IPPROTO_ICMP (" + STR$(ipProto) + ") - Ping"
        IF itemID = 6 THEN PRINT "  IPPROTO_TCP (" + STR$(ipProto) + ") - Reliable stream"
        IF itemID = 7 THEN PRINT "  IPPROTO_UDP (" + STR$(ipProto) + ") - Datagram"
        IF itemID = 8 THEN PRINT "  IPPROTO_IGMP (" + STR$(ipProto) + ") - Multicast"

        IF itemID = 9 THEN httpMethod = 1
        IF itemID = 10 THEN httpMethod = 2
        IF itemID = 11 THEN httpMethod = 3
        IF itemID = 12 THEN httpMethod = 4

        IF itemID = 9 THEN PRINT "  HTTP GET - Retrieve resource"
        IF itemID = 10 THEN PRINT "  HTTP POST - Submit data"
        IF itemID = 11 THEN PRINT "  HTTP PUT - Upload resource"
        IF itemID = 12 THEN PRINT "  HTTP DELETE - Remove resource"

        IF itemID = 13 THEN httpStatus = 200
        IF itemID = 14 THEN httpStatus = 301
        IF itemID = 15 THEN httpStatus = 404
        IF itemID = 16 THEN httpStatus = 500

        IF itemID = 13 THEN PRINT "  HTTP 200 OK"
        IF itemID = 14 THEN PRINT "  HTTP 301 Moved Permanently"
        IF itemID = 15 THEN PRINT "  HTTP 404 Not Found"
        IF itemID = 16 THEN PRINT "  HTTP 500 Internal Server Error"

        IF itemID = 17 THEN dnsRecordType = 1
        IF itemID = 18 THEN dnsRecordType = 2

        IF itemID = 17 THEN PRINT "  DNS A record - IPv4 address"
        IF itemID = 18 THEN PRINT "  DNS AAAA record - IPv6 address"

        IF socketType = 1 THEN PRINT "  SOCK_STREAM (" + STR$(socketType) + ") - TCP"
        IF socketType = 2 THEN PRINT "  SOCK_DGRAM (" + STR$(socketType) + ") - UDP"
        IF socketType = 3 THEN PRINT "  SOCK_RAW (" + STR$(socketType) + ") - Raw"
        IF socketType = 4 THEN PRINT "  SOCK_SEQPACKET (" + STR$(socketType) + ") - Seq"
    NEXT totalItems

    PRINT "=== End Net Constants ==="
    FUNCTION = 0
END FUNCTION
