… | |
… | |
33 | u32 host; |
33 | u32 host; |
34 | u16 port; |
34 | u16 port; |
35 | u8 prot; |
35 | u8 prot; |
36 | u8 pad1; |
36 | u8 pad1; |
37 | |
37 | |
38 | void set (const sockaddr_in *sa, u8 prot_ = PROT_UDPv4); |
38 | void set (const sockaddr_in *sa, u8 prot_); |
39 | void set (const conf_node *conf); |
39 | void set (const conf_node *conf, u8 prot_); |
|
|
40 | void set (const char *hostname, u16 port_, u8 prot_); |
|
|
41 | |
|
|
42 | // return the supported protocols |
|
|
43 | u8 supported_protocols (conf_node *conf = 0); |
|
|
44 | bool upgrade_protocol (u8 prot_, conf_node *conf = 0); |
40 | |
45 | |
41 | operator const char *() const; |
46 | operator const char *() const; |
42 | |
47 | |
43 | const sockaddr *sav4 () const; |
48 | const sockaddr *sav4 () const; |
44 | const socklen_t salenv4 () const |
49 | const socklen_t salenv4 () const |
45 | { |
|
|
46 | return sizeof (sockaddr_in); |
50 | { return sizeof (sockaddr_in); } |
47 | } |
|
|
48 | |
51 | |
49 | const char *ntoa () const; |
52 | const char *ntoa () const; |
50 | |
53 | |
51 | sockinfo() |
54 | bool valid () const |
52 | { |
55 | { return prot != 0 && host != 0; } |
53 | prot = 0; |
|
|
54 | } |
|
|
55 | |
56 | |
|
|
57 | sockinfo() { prot = 0; } |
|
|
58 | |
56 | sockinfo(const sockaddr_in &sa, u8 prot_ = PROT_UDPv4) |
59 | sockinfo(const sockaddr_in &sa, u8 prot) |
57 | { |
|
|
58 | set (&sa, prot_); |
60 | { set (&sa, prot); } |
59 | } |
61 | |
|
|
62 | sockinfo(const conf_node *conf, u8 prot) |
|
|
63 | { set (conf, prot); } |
60 | }; |
64 | }; |
61 | |
65 | |
62 | inline bool |
|
|
63 | operator == (const sockinfo &a, const sockinfo &b) |
66 | bool operator == (const sockinfo &a, const sockinfo &b); |
64 | { |
67 | bool operator < (const sockinfo &a, const sockinfo &b); |
65 | return a.host == b.host && a.port == b.port && a.prot == b.prot; |
|
|
66 | } |
|
|
67 | |
68 | |
68 | #endif |
69 | #endif |
69 | |
70 | |