method SocketAddr.parse
ip:port or [v6]:port with numeric addresses (SocketAddr.parse("127.0.0.1:8080")).
Example:
use std.net { SocketAddr }
fn main() io {
match SocketAddr.parse("localhost:80") {
SocketAddr a => print(a.toString())
ParseError e => print(e.msg)
}
}Output
invalid socket address `localhost:80`
pub(api) static fn parse(text: str) -> SocketAddr | ParseErrorComplexity. O(n) in the length of the text.
Since. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
text | str |
Returns
Errors
ParseError@error- `ParseError` when the text is not `ip:port` / `[v6]:port` with a numeric address and a port in 0..65535.
Effects
none declared (pure unless the body says otherwise)
Defined in: std/net/net.oxl:294