net/socket_type.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.socket
#
# -----------------------------------------------------------------------
# defines constants for socket types which
# specify the communication semantics to
# used in a socket.
#
public socket_type is
# connection-based byte-stream
# this must be used for TCP
public stream is
# connection-less messages with fixed maximum length
# this must be used for UDP
public datagram is
private:module val : choice socket_type.stream datagram is
module as_num i32 =>
match val.this
socket_type.stream => 1
datagram => 2
# convenience feature to get the socket type by used protocol
module by_protocol(p protocol.val) net.socket_type.val =>
match p
protocol.tcp => net.socket_type.stream
protocol.udp => net.socket_type.datagram
nil => panic "not supported"
last changed: 2024-03-07