com.scalacraft.domain.v2.net
A Port represents an IP port.
Port
The following constraints hold for instances of this class,
- portNumber is in the range [0, 65535]
portNumber
An instance can be created using a suitable overload of the opt method.
opt
val portOpt: Option[Port] = Port.opt(1908) val portOpt2: Option[Port] = Port.opt("40115")
When any class constraint is violated the result is None.
None
Pattern matching is supported as the following examples demonstrate,
7 match { case Port(p) => p // 7 case _ => None }
The match target can be a string,
val s: String = ... s match { case Port(p) => p case _ => None }
Invalid ports are not matched,
-129 match { case Port(p) => p case _ => None // None }
Implicit conversions exists which allow an instance of Port to be used when an Int or String is required.
Int
String
val port = Port.opt(6006) val sa = port map { p => new InetSocketAddress(p) }
A conversion to the unconstrained version of this class is also available.
A
Portrepresents an IP port.The following constraints hold for instances of this class,
-
portNumberis in the range [0, 65535]An instance can be created using a suitable overload of the
optmethod.When any class constraint is violated the result is
None.Pattern Matching
Pattern matching is supported as the following examples demonstrate,
The match target can be a string,
Invalid ports are not matched,
Implicit Conversions
Implicit conversions exists which allow an instance of
Portto be used when anIntorStringis required.A conversion to the unconstrained version of this class is also available.