|
| Network (int peer_count, int channel_limit, uint32_t max_incoming_bandwidth, uint32_t max_outgoing_bandwidth, ENetAddress *address, bool change_port_if_bound=false) |
| Constructor that just initialises this object (esp.
|
|
virtual | ~Network () |
| Destructor.
|
|
ENetPeer * | connectTo (const ENetAddress &address) |
|
void | sendRawPacket (const BareNetworkString &buffer, const SocketAddress &dst) |
| Sends a packet whithout ENet adding its headers.
|
|
int | receiveRawPacket (char *buffer, int buf_len, SocketAddress *sender, int max_tries=-1) |
| Receives a packet directly from the network interface and filter its address.
|
|
void | broadcastPacket (NetworkString *data, bool reliable=true) |
| Broadcasts a packet to all peers.
|
|
uint16_t | getPort () const |
|
ENetHost * | getENetHost () |
| Returns a pointer to the ENet host object.
|
|
bool | isIPv6Socket () |
|
|
static bool | m_connection_debug = false |
|
|
ENetHost * | m_host |
| ENet host interfacing sockets.
|
|
uint16_t | m_port |
|
bool | m_ipv6_socket |
|
◆ Network()
Network::Network |
( |
int |
peer_count, |
|
|
int |
channel_limit, |
|
|
uint32_t |
max_incoming_bandwidth, |
|
|
uint32_t |
max_outgoing_bandwidth, |
|
|
ENetAddress * |
address, |
|
|
bool |
change_port_if_bound = false |
|
) |
| |
Constructor that just initialises this object (esp.
opening the packet log file), but it does not start a listener thread.
- Parameters
-
peer_count | : The maximum number of peers. |
channel_limit | : The maximum number of channels per peer. |
max_incoming_bandwidth | : The maximum incoming bandwidth. |
max_outgoing_bandwidth | : The maximum outgoing bandwidth. |
change_port_if_bound | : Use another port if the prefered port is already bound to a socket. |
◆ ~Network()
Destructor.
Stops the listening thread, closes the packet log file and destroys the enet host.
◆ broadcastPacket()
void Network::broadcastPacket |
( |
NetworkString * |
data, |
|
|
bool |
reliable = true |
|
) |
| |
Broadcasts a packet to all peers.
- Parameters
-
◆ logPacket()
Log packets into a file.
- Parameters
-
ns | : The data in the packet |
incoming | : True if the packet comes from a peer. False if it's sent to a peer. |
◆ receiveRawPacket()
int Network::receiveRawPacket |
( |
char * |
buffer, |
|
|
int |
buf_len, |
|
|
SocketAddress * |
sender, |
|
|
int |
max_tries = -1 |
|
) |
| |
Receives a packet directly from the network interface and filter its address.
Receive a packet whithout ENet processing it. Checks that the sender of the packet is the one that corresponds to the sender parameter. Does not check the port right now.
- Parameters
-
| buffer | A buffer to receive the data in. |
| buf_len | Length of the buffer. |
[out] | sender | : Transport address of the original sender of the wanted packet. If the ip address is 0, do not check the sender's ip address, otherwise wait till a message from the specified sender arrives. All other messages are discarded. |
| max_tries | : Number of times we try to read data from the socket. This is aproximately the time we wait in milliseconds. -1 means eternal tries. |
- Returns
- Length of the received data, or -1 if no data was received.
◆ sendRawPacket()
Sends a packet whithout ENet adding its headers.
This function is used in particular to achieve the STUN protocol.
- Parameters
-
data | : Data to send. |
dst | : Destination of the packet. |
◆ m_log_file
Where to log packets.
If NULL for FILE* logging is disabled.
The documentation for this class was generated from the following files: