Summary: Moved server and worker from bolt to communication. Started templatization. Started removal of Bolt class. Removed unnecessary files from network. Converted states to template functions. Bolt::Session is now a template. Merge remote-tracking branch 'origin/dev' into mg_refactor_network Merged bolt_serializer.cpp into hpp. Removed obsolete include. Initial version of bolt session unit test. Uncommented leftover log commands. Reimplemented io::Socket. Added client-stress.sh script. Reviewers: dgleich, buda Reviewed By: dgleich, buda Subscribers: pullbot, mferencevic, buda Differential Revision: https://phabricator.memgraph.io/D64
33 lines
787 B
C++
33 lines
787 B
C++
#include <netdb.h>
|
|
#include <cstring>
|
|
|
|
#include "io/network/addrinfo.hpp"
|
|
|
|
#include "io/network/network_error.hpp"
|
|
#include "utils/underlying_cast.hpp"
|
|
|
|
namespace io::network {
|
|
|
|
AddrInfo::AddrInfo(struct addrinfo* info) : info(info) {}
|
|
|
|
AddrInfo::~AddrInfo() { freeaddrinfo(info); }
|
|
|
|
AddrInfo AddrInfo::Get(const char* addr, const char* port) {
|
|
struct addrinfo hints;
|
|
memset(&hints, 0, sizeof(struct addrinfo));
|
|
|
|
hints.ai_family = AF_UNSPEC; // IPv4 and IPv6
|
|
hints.ai_socktype = SOCK_STREAM; // TCP socket
|
|
hints.ai_flags = AI_PASSIVE;
|
|
|
|
struct addrinfo* result;
|
|
auto status = getaddrinfo(addr, port, &hints, &result);
|
|
|
|
if (status != 0) throw NetworkError(gai_strerror(status));
|
|
|
|
return AddrInfo(result);
|
|
}
|
|
|
|
AddrInfo::operator struct addrinfo*() { return info; }
|
|
}
|