The purpose of the PortNumberType is to define a type capturing the concepts of a Port Number used in networking. Port Numbers can range from 0 to 65353. However, there are restrictions that apply when assigning port numbers. Walter Goralski 1) provides the following explanation.
The parameters that are marked as STATIC
can only be set once when the TYPE
is being defined and is shared amongst all instances created from the PortNumberType
. The PortNumberType
is inclusive that covers all the possible Port Numbers that can be defined.
DEFINE TYPE PortNumberType ( VALUE : PositiveWholeNumber, MIN : PositiveWholeNumber STATIC := 0, MAX : PositiveWholeNumber STATIC := 65353, DEFAULT : PositiveWholeNumber STATIC := 80, units : PositiveWholeNumber STATIC := "PortNumber" ) AS PositiveWholeNumber ALLOWING NONULL WITH CONSTRAINTS ( VALUE = NVL (VALUE, DEFAULT), MIN = MIN, MAX = MAX, DEFAULT = DEFAULT, UNITS = units );
CREATE portNumber PortNumberType = NEW PortNumberType ( value = 80 );
DEFINE TYPE WellKnownPortType ( VALUE : PortNumberType, MIN : PortNumberType STATIC := 0, MAX : PortNumberType STATIC := 1023, DEFAULT : PortNumberType STATIC := 80, units : PortNumberType STATIC := "PortNumber" ) AS PortNumberType ALLOWING NONULL WITH CONSTRAINTS ( VALUE = DEFAULT, MIN = MIN, MAX = MAX, DEFAULT = DEFAULT, UNITS = units ); CREATE httpPortNumber = NEW WellKnownPortType ( VALUE = 80 );
DEFINE TYPE RegisteredPortType ( VALUE : PortNumberType, MIN : PortNumberType STATIC := 1024, MAX : PortNumberType STATIC := 49151, DEFAULT : PortNumberType STATIC := 8080, units : PortNumberType STATIC := "PortNumber" ) AS PortNumberType ALLOWING NONULL WITH CONSTRAINTS ( VALUE = DEFAULT, MIN = MIN, MAX = MAX, DEFAULT = DEFAULT, UNITS = units ); CREATE WebServerPortNumber = NEW WellKnownPortType ( VALUE = 8080 );
DEFINE TYPE DynamicPortType ( VALUE : PortNumberType, MIN : PortNumberType STATIC := 49152, MAX : PortNumberType STATIC := 65535, DEFAULT : PortNumberType STATIC := 30303, units : PortNumberType STATIC := "PortNumber" ) AS PortNumberType ALLOWING NONULL WITH CONSTRAINTS ( VALUE = DEFAULT, MIN = MIN, MAX = MAX, DEFAULT = DEFAULT, UNITS = units );
The following are some examples of defining Port Numbers constants for specific DIDO Platforms.
DEFINE CONSTANT EthereumTcpPortNumber = NEW DynamicPortType ( VALUE = 30303 ); --% Used as a Listener Port DEFINE CONSTANT EthereumUdpPortNumber = NEW DynamicPortType ( VALUE = 30303 ); --% Used as a Discovery Port DEFINE CONSTANT IotaApiPortNumber = NEW DynamicPortType ( VALUE = 14700 ); --% Used by Wallets DEFINE CONSTANT IotaTcpSyncPortNumber = NEW DynamicPortType ( VALUE = 14265 ); --% Used to talk to neighbors over TCP DEFINE CONSTANT IotaUdpSyncPortNumber = NEW DynamicPortType ( VALUE = 14700 ); --% Used to talk to neighbors over UDP DEFINE CONSTANT IpfsApiPortNumber = NEW RegisteredPortType ( VALUE = 5001 ); --% Used by APIs DEFINE CONSTANT IpfsGatewayPortNumber = NEW RegisteredPortType ( VALUE = 8080 ); --% Used by Gateway DEFINE CONSTANT IpfsSwarmPortNumber = NEW RegisteredPortType ( VALUE = 4001 ); --% Used by Swarm DEFINE CONSTANT DdsDiscoveryMulticastPortNumber = NEW RegisteredPortType ( VALUE = 5001 ); --% Used by All Applications DEFINE CONSTANT DdsUserMulticastPortNumber = NEW RegisteredPortType ( VALUE = 8080 ); --% Used by All Applications