Added linux includes for networking

TcpClient: added close_connection to shutdown the connection on both send and receive
TcpServer: changed clients list initialization from constructors to using the reserve function
This commit is contained in:
xX-TheDoctor-Xx
2016-09-16 20:38:30 +01:00
parent 3e97c0da6d
commit a9549c33e3
11 changed files with 23 additions and 3 deletions

View File

@ -245,4 +245,12 @@ enum InternalTags
#define IS_HANDSHAKE(name) name.subject == 1 || (name.tag == DisconnectTag || name.tag == ConnectTag || name.tag == Accept || name.tag == Close || name.tag == Reject)
#ifdef __linux__
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
void closesocket(int socket) { close(socket); }
#endif
#endif // DEFS_HPP

View File

@ -57,6 +57,7 @@ private:
const NetworkBuffer &receive_data_array();
static void receive_data(TcpClient *client);
static bool send_network_message(const NetworkMessage &message, TcpClient *client);
static void close_connection(TcpClient *client);
bool initialize(const std::string &ip, uint16 port = default_client_port);