This commit is contained in:
2018-05-09 23:45:32 +02:00
parent cfadefbbf9
commit a83776dc78
2 changed files with 39 additions and 8 deletions

View File

@ -1,4 +1,4 @@
install: install:
@echo "Start compiling..." @echo "Start compiling..."
g++ ./src/necronda-server.cpp -o ./bin/necronda-server g++ src/necronda-server.cpp -o bin/necronda-server -std=c++17 -fPIC
@echo "Finished compiling!" @echo "Finished compiling!"

View File

@ -7,19 +7,50 @@
#include <iostream> #include <iostream>
#include "http/HttpHeader.cpp" #include "network/Connection.cpp"
#include "network/http/HttpHeader.cpp"
using namespace std; using namespace std;
int main() { int main() {
cout << "Hello, World!1" << endl; cout << "Necronda Server 3.0" << endl << "by Lorenz Stechauner" << endl << endl;
HttpHeader *header = new HttpHeader();
header->setField("Content-Length", "80"); unsigned short PORT = 8080;
header->setField("Hermann", "500");
Connection *s;
try {
s = new Connection();
} catch (char *msg) {
cout << "Unable to create socket: " << msg << endl;
exit(1);
}
try {
s->bind(PORT);
} catch (char *msg) {
cout << "Unable to bind socket to port " << PORT << ": " << msg << endl;
exit(2);
}
try {
s->listen(256);
} catch (char *msg) {
cout << "Unable to listen on socket: " << msg << endl;
exit(3);
}
while (true) {
try {
Connection *client = s->accept();
cout << client->getPeerAddress()->toString() << ":" << client->getPeerPort() << " <-> "
<< client->getSocketAddress()->toString() << ":" << client->getSocketPort() << endl;
} catch (char *msg) {
cout << msg << endl;
break;
}
}
cout << header->getField("Content-Length") << " " << header->getField("Hermand") << endl;
return 0; return 0;
} }