22#ifndef HEADER_NETWORK_HPP
23#define HEADER_NETWORK_HPP
25#include "utils/synchronised.hpp"
31#define WIN32_LEAN_AND_MEAN
58 static bool m_connection_debug;
59 Network(
int peer_count,
int channel_limit,
60 uint32_t max_incoming_bandwidth,
61 uint32_t max_outgoing_bandwidth,
63 bool change_port_if_bound =
false);
66 static void openLog();
68 static void closeLog();
69 ENetPeer *connectTo(
const ENetAddress &address);
75 bool reliable =
true);
77 uint16_t getPort()
const {
return m_port; }
82 bool isIPv6Socket() {
return m_ipv6_socket; }
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:53
A new implementation of NetworkString, which has a fixed format: Byte 0: The type of the message,...
Definition: network_string.hpp:422
Definition: network.hpp:46
void broadcastPacket(NetworkString *data, bool reliable=true)
Broadcasts a packet to all peers.
Definition: network.cpp:214
ENetHost * getENetHost()
Returns a pointer to the ENet host object.
Definition: network.hpp:80
virtual ~Network()
Destructor.
Definition: network.cpp:112
static Synchronised< FILE * > m_log_file
Where to log packets.
Definition: network.hpp:55
static void logPacket(const BareNetworkString &ns, bool incoming)
Log packets into a file.
Definition: network.cpp:243
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.
Definition: network.cpp:163
ENetHost * m_host
ENet host interfacing sockets.
Definition: network.hpp:49
void sendRawPacket(const BareNetworkString &buffer, const SocketAddress &dst)
Sends a packet whithout ENet adding its headers.
Definition: network.cpp:132
Describes a IPv4 or IPv6 address in sockaddr_in(6) format, suitable in using with sendto.
Definition: socket_address.hpp:47
A variable that is automatically synchronised using pthreads mutex.
Definition: synchronised.hpp:28
Declares the general types that are used by the network.