1 #ifndef NETWORK_ADDRESS_H |
1 #ifndef NETWORK_ADDRESS_H |
2 #define NETWORK_ADDRESS_H |
2 #define NETWORK_ADDRESS_H |
3 |
3 |
|
4 /** |
|
5 * @file |
|
6 * |
|
7 * Binary NetworkAddress |
|
8 */ |
|
9 |
|
10 #include "Platform.hh" |
4 #include "Endpoint.hh" |
11 #include "Endpoint.hh" |
5 |
12 |
6 /* |
|
7 * Platform-specific includes |
|
8 */ |
|
9 #ifndef WIN32 |
|
10 // linux |
|
11 #include <netinet/in.h> |
|
12 #else |
|
13 #error "This network code won't compile on win32 :)" |
|
14 #endif |
|
15 |
|
16 /** |
13 /** |
17 * This represents a `struct sockaddr` as used by the socket API. |
14 * A NetworkAddress represents a single network address in the form of a `struct sockaddr`, as used by the OS's socket |
|
15 * API. A NetworkAddress's value may only be constructed/manipulated in sockaddr form, and the class then emulates the |
|
16 * get_addrinfo (by building our own addrinfo struct value) and get_hostname()/get_service() (by using libc's |
|
17 * getnameinfo() when the address is updated). |
18 * |
18 * |
19 * It can be used like a NetworkEndpoint, but it's also suitable for use with recvfrom/sendto |
19 * This means that a NetworkAddress can be used like a NetworkEndpoint (like a literal IP address), but can also be |
|
20 * used in a more specifc fashion like NetworkSocket::send or NetworkSocket::accept, where a definitive address is |
|
21 * required. |
|
22 * |
|
23 * XXX: currently, there is no way to form a NetworkAddress from a NetworkEndpoint for e.g. sending UDP packets without |
|
24 * an associated TCP connection. |
20 */ |
25 */ |
21 class NetworkAddress : public NetworkEndpoint { |
26 class NetworkAddress : public NetworkEndpoint { |
22 protected: |
27 protected: |
23 /** |
28 /** |
24 * The machine-readable address |
29 * The machine-readable address |