Optimizations.
This commit is contained in:
1 parent
7e43656c5c
commit
96d9295df8
7 files changed
+34
-30
No files matched your search
+19
-16
@@ -6,24 +6,27 @@
|
||||
|
||||
namespace core {
|
||||
|
||||
TCPServer::TCPServer(EPoll &ePoll, IPAddress address, std::string delimiter, std::string text)
|
||||
: TCPSocket(ePoll, text), commands(delimiter) {
|
||||
TCPServer::TCPServer(EPoll &ePoll, IPAddress address, std::string delimiter, int depth, std::string text)
|
||||
: TCPSocket(ePoll, text), commands(delimiter, depth) {
|
||||
|
||||
commands.add(subscriptions, "publish");
|
||||
commands.add(subscriptions, "unpublish");
|
||||
commands.add(subscriptions, "subscribe");
|
||||
commands.add(subscriptions, "unsubscribe");
|
||||
commands.add(subscriptions, "catalog");
|
||||
commands.add(subscriptions, "event");
|
||||
commands.add(subscriptions, "publish");
|
||||
commands.add(subscriptions, "unpublish");
|
||||
commands.add(subscriptions, "subscribe");
|
||||
commands.add(subscriptions, "unsubscribe");
|
||||
commands.add(subscriptions, "catalog");
|
||||
commands.add(subscriptions, "event");
|
||||
|
||||
setDescriptor(socket(AF_INET, SOCK_STREAM, 0));
|
||||
int yes = 1;
|
||||
setsockopt(getDescriptor(), SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int));
|
||||
if(bind(getDescriptor(), address.getPointer(), address.addressLength) < 0)
|
||||
throw coreutils::Exception("Error on bind to socket: " + std::to_string(errno));
|
||||
if(listen(getDescriptor(), 20) < 0)
|
||||
throw coreutils::Exception("Error on listen to socket");
|
||||
}
|
||||
setDescriptor(socket(AF_INET, SOCK_STREAM, 0));
|
||||
int yes = 1;
|
||||
setsockopt(getDescriptor(), SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int));
|
||||
|
||||
if(bind(getDescriptor(), address.getPointer(), address.addressLength) < 0)
|
||||
throw coreutils::Exception("Error on bind to socket: " + std::to_string(errno));
|
||||
|
||||
if(listen(getDescriptor(), 20) < 0)
|
||||
throw coreutils::Exception("Error on listen to socket");
|
||||
|
||||
}
|
||||
|
||||
TCPServer::~TCPServer() {
|
||||
coreutils::Log(coreutils::LOG_DEBUG_2) << "Closing server socket " << getDescriptor() << ".";
|
||||
|
||||
Reference in new issue
Block a user