MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / parse_port

Function parse_port

net/kernel_socket.cpp:1054–1064  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1052/* Implementations in socket.h */
1053
1054static int parse_port(estring_view& ep) {
1055 auto pos = ep.find_last_of(':');
1056 if (pos == estring::npos) return -1;
1057 auto port_str = ep.substr(pos + 1);
1058 if (!port_str.all_digits()) return -1;
1059 auto port = port_str.to_uint64();
1060 if (port > UINT16_MAX) return -1;
1061 ep = (pos > 2 && ep[0] == '[') ? ep.substr(1, pos - 2)
1062 : ep.substr(0, pos);
1063 return (int)port;
1064}
1065
1066static void parse_addr(std::string_view s, IPAddr* addr) {
1067 if (s.length() >= INET6_ADDRSTRLEN - 1) return;

Callers 2

EndPointMethod · 0.85
parseMethod · 0.85

Calls 4

find_last_ofMethod · 0.80
substrMethod · 0.45
all_digitsMethod · 0.45
to_uint64Method · 0.45

Tested by

no test coverage detected