It's not necessary to use EPOLL_CTL_DEL after close()

This commit is contained in:
Ian Gulliver
2015-02-05 20:57:01 +00:00
parent 524434813c
commit c91b64f892
3 changed files with 42 additions and 20 deletions

View File

@@ -1,5 +1,7 @@
#include <fstream>
#include <iostream>
#include <getopt.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
@@ -8,7 +10,33 @@
#include "crypto.h"
int main() {
static const struct option long_options[] = {
{"secret_key_filename", required_argument, NULL, 's'},
};
int main(int argc, char *argv[]) {
std::string secret_key_filename;
{
int option, option_index;
while ((option = getopt_long(argc, argv, "s:", long_options, &option_index)) != -1) {
switch (option) {
case 's':
secret_key_filename = optarg;
break;
}
}
}
std::string secret_key;
{
std::fstream secret_key_file(secret_key_filename, std::fstream::in);
if (secret_key_file.fail()) {
std::cerr << "Failed to open secret key file" << std::endl;
return 1;
}
secret_key_file >> secret_key;
}
int fd = socket(PF_INET6, SOCK_STREAM, 0);
int optval = 1;
@@ -29,6 +57,6 @@ int main() {
return 1;
}
CryptoPubServer server(fd, "abcde");
CryptoPubServer server(fd, secret_key);
server.Loop();
}