Progress
This commit is contained in:
2
Makefile
2
Makefile
@ -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!"
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user