How to get host and port for SocketAddress object?

In Rust, I can use to_string() trait implementation but the string includes host:port together.

Can I convert or cast this object into another type to get host and port separately, without parsing the dumped string?

Thanks

InetSocketAddress has address and port properties.

UnixSocketAddress has path property.

1 Like