![]() |
DDraceNetwork Documentation
|
Modules | |
| Network-UDP | |
| Network-TCP | |
| Network-Unix-Sockets | |
Classes | |
| struct | NETADDR |
| struct | NETSTATS |
Typedefs | |
| typedef int | UNIXSOCKET |
| typedef struct sockaddr_un | UNIXSOCKETADDR |
| typedef struct NETSOCKET_INTERNAL * | NETSOCKET |
| typedef struct NETADDR | NETADDR |
| typedef struct NETSTATS | NETSTATS |
Functions | |
| void | net_init () |
| int | net_host_lookup (const char *hostname, NETADDR *addr, int types) |
| int | net_addr_comp (const NETADDR *a, const NETADDR *b) |
| int | net_addr_comp_noport (const NETADDR *a, const NETADDR *b) |
| void | net_addr_str (const NETADDR *addr, char *string, int max_length, bool add_port) |
| int | net_addr_from_url (NETADDR *addr, const char *string, char *host_buf, size_t host_buf_size) |
| bool | net_addr_is_local (const NETADDR *addr) |
| int | net_addr_from_str (NETADDR *addr, const char *string) |
| int | net_set_non_blocking (NETSOCKET sock) |
| int | net_errno () |
| std::string | net_error_message () |
| int | net_would_block () |
| int | net_socket_read_wait (NETSOCKET sock, std::chrono::nanoseconds nanoseconds) |
| int | net_socket_type (NETSOCKET sock) |
Compares two network addresses.
| a | Address to compare. |
| b | Address to compare to. |
< 0 if address a is less than address b. 0 if address a is equal to address b. > 0 if address a is greater than address b. Compares two network addresses ignoring port.
| a | Address to compare. |
| b | Address to compare to. |
< 0 if address a is less than address b. 0 if address a is equal to address b. > 0 if address a is greater than address b. Turns string into a network address.
| addr | Address to fill in. |
| string | String to parse. |
0 on success. | int net_addr_from_url | ( | NETADDR * | addr, |
| const char * | string, | ||
| char * | host_buf, | ||
| size_t | host_buf_size | ||
| ) |
Turns url string into a network address struct. The url format is tw-0.6+udp://{ipaddr}[:{port}] ipaddr: can be ipv4 or ipv6 port: is a optional internet protocol port
This format is used for parsing the master server, be careful before changing it.
Examples: tw-0.6+udp://127.0.0.1 tw-0.6+udp://127.0.0.1:8303
| addr | Address to fill in. |
| string | String to parse. |
| host_buf | Pointer to a buffer to write the host to It will include the port if one is included in the url It can also be set to nullptr then it will be ignored. |
| host_buf_size | Size of the host buffer or 0 if no host_buf pointer is given. |
0 on success. > 0 if the input wasn't a valid DDNet URL, < 0 if the input is a valid DDNet URL but the host part was not a valid IPv4/IPv6 address Checks if an address is local.
| addr | Address to check. |
true if the address is local, false otherwise. Turns a network address into a representative string.
| addr | Address to turn into a string. |
| string | Buffer to fill with the string. |
| max_length | Maximum size of the string. |
| add_port | Whether to add the port to the string. |
| int net_errno | ( | ) |
If a network operation failed, the error code.
| std::string net_error_message | ( | ) |
If a network operation failed, the platform-specific error code and string.
Looks up the ip of a hostname.
| hostname | Host name to look up. |
| addr | The output address to write to. |
| types | The type of IP that should be returned. |
0 on success. | void net_init | ( | ) |
Initiates network functionality.
Make a socket not block on operations
| sock | The socket to set the mode on. |
0 on success. Waits for a socket to have data available to receive up the specified timeout duration.
| sock | Socket to wait on. |
| nanoseconds | Timeout duration to wait. |
1 if data was received within the timeout duration, 0 otherwise. Determine a socket's type.
| sock | Socket whose type should be determined. |
NETTYPE_IPV4, NETTYPE_IPV6, NETTYPE_WEBSOCKET_IPV4 and NETTYPE_WEBSOCKET_IPV6, or NETTYPE_INVALID if the socket is invalid. | int net_would_block | ( | ) |
Determines whether a network operation would block.
0 if wouldn't block, 1 if would block.