A combination of a network address (CNetAddr) and a (TCP) port */
| 525 | |
| 526 | /** A combination of a network address (CNetAddr) and a (TCP) port */ |
| 527 | class CService : public CNetAddr |
| 528 | { |
| 529 | protected: |
| 530 | uint16_t port; // host order |
| 531 | |
| 532 | public: |
| 533 | CService(); |
| 534 | CService(const CNetAddr& ip, uint16_t port); |
| 535 | CService(const struct in_addr& ipv4Addr, uint16_t port); |
| 536 | explicit CService(const struct sockaddr_in& addr); |
| 537 | uint16_t GetPort() const; |
| 538 | bool GetSockAddr(struct sockaddr* paddr, socklen_t* addrlen) const; |
| 539 | bool SetSockAddr(const struct sockaddr* paddr); |
| 540 | friend bool operator==(const CService& a, const CService& b); |
| 541 | friend bool operator!=(const CService& a, const CService& b) { return !(a == b); } |
| 542 | friend bool operator<(const CService& a, const CService& b); |
| 543 | std::vector<unsigned char> GetKey() const; |
| 544 | std::string ToString() const; |
| 545 | std::string ToStringPort() const; |
| 546 | std::string ToStringIPPort() const; |
| 547 | |
| 548 | CService(const struct in6_addr& ipv6Addr, uint16_t port); |
| 549 | explicit CService(const struct sockaddr_in6& addr); |
| 550 | |
| 551 | SERIALIZE_METHODS(CService, obj) |
| 552 | { |
| 553 | READWRITEAS(CNetAddr, obj); |
| 554 | READWRITE(Using<BigEndianFormatter<2>>(obj.port)); |
| 555 | } |
| 556 | |
| 557 | friend class CServiceHash; |
| 558 | friend CService MaybeFlipIPv6toCJDNS(const CService& service); |
| 559 | }; |
| 560 | |
| 561 | class CServiceHash |
| 562 | { |
no outgoing calls