Fuzion Logo
fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

net/protocol.fz


# This file is part of the Fuzion language implementation.
#
# The Fuzion language implementation is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, version 3 of the License.
#
# The Fuzion language implementation is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU General Public License along with The
# Fuzion language implementation.  If not, see <https://www.gnu.org/licenses/>.


# -----------------------------------------------------------------------
#
#  Tokiwa Software GmbH, Germany
#
#  Source code of Fuzion standard library feature net.protocol
#
# -----------------------------------------------------------------------

# defines constants for network protocols that
# can be used for network communication.
# usually there is only one possible protocol
# for each pair of family and socket type.
#
public protocol is

  public tcp is
    public redef as_string => "TCP"

  public udp is
    public redef as_string => "UDP"

  public val : choice tcp udp nil is
    module as_num i32 =>
      match val.this
        tcp  => 6
        udp  => 17
        nil  => -1

    public redef as_string =>
      match val.this
        t tcp   => t.as_string
        u udp   => u.as_string
        nil     => "none"