How to get host and port for SocketAddress object? (original) (raw)

d47081 (D47081)

March 22, 2025, 9:02pm 1

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

Sid (Sid) March 23, 2025, 3:21am 2

InetSocketAddress has address and port properties.

UnixSocketAddress has path property.

system (system) Closed April 22, 2025, 3:22am 3

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.