diff --git a/.cache/clangd/index/http.c.2032D7AF431E6769.idx b/.cache/clangd/index/http.c.2032D7AF431E6769.idx deleted file mode 100644 index f955cce..0000000 Binary files a/.cache/clangd/index/http.c.2032D7AF431E6769.idx and /dev/null differ diff --git a/.cache/clangd/index/http.h.CBA685791671AF76.idx b/.cache/clangd/index/http.h.CBA685791671AF76.idx deleted file mode 100644 index 8f8c41a..0000000 Binary files a/.cache/clangd/index/http.h.CBA685791671AF76.idx and /dev/null differ diff --git a/.cache/clangd/index/main.c.5F7C0974CF7C54AB.idx b/.cache/clangd/index/main.c.5F7C0974CF7C54AB.idx deleted file mode 100644 index efacf29..0000000 Binary files a/.cache/clangd/index/main.c.5F7C0974CF7C54AB.idx and /dev/null differ diff --git a/.cache/clangd/index/main.cpp.C52265A3E70D3278.idx b/.cache/clangd/index/main.cpp.C52265A3E70D3278.idx deleted file mode 100644 index 8d1e9df..0000000 Binary files a/.cache/clangd/index/main.cpp.C52265A3E70D3278.idx and /dev/null differ diff --git a/DesignedWorlds b/DesignedWorlds index d5ef02e..fb8c2ac 100755 Binary files a/DesignedWorlds and b/DesignedWorlds differ diff --git a/source/http.h b/source/http.h index e7c6feb..040de46 100644 --- a/source/http.h +++ b/source/http.h @@ -8,6 +8,8 @@ #ifndef HTTP_H #define HTTP_H +#define HTTP_PORT 9090 + #define HTTP_UNKNOWN 0 #define HTTP_GET 1 #define HTTP_POST 2 diff --git a/source/main.c b/source/main.c index ed23c47..57ed265 100644 --- a/source/main.c +++ b/source/main.c @@ -46,11 +46,17 @@ void handleClient(int sock) { memcpy(packetBuilder, tmp, tmpSize); free(tmp); memcpy(&packetBuffer[tmpSize], packetBuilder, sizeOfPacket); + if(sizeOfPacket < HTTP_RECIVE_PACKET_SIZE) { + break; + } continue; } memcpy(packetBuffer, packetBuilder, sizeOfPacket); + if(sizeOfPacket < HTTP_RECIVE_PACKET_SIZE) { + break; + } - } + } if(sizeOfPacket < 0) { exit(-1); } @@ -106,10 +112,12 @@ int main() { perror("socket"); return -1; } + int opts = 1; + setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &opts, sizeof(opts)); struct sockaddr_in addr; addr.sin_family = AF_INET; - addr.sin_port = htons(9091); + addr.sin_port = htons(HTTP_PORT); inet_pton(AF_INET, "127.0.0.1", &addr.sin_addr); if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {