diff --git a/srcs/main.cpp b/srcs/main.cpp index 4ef15dc..eecfa30 100644 --- a/srcs/main.cpp +++ b/srcs/main.cpp @@ -1,4 +1,34 @@ +/* + luke version +*/ + +#include +#include +#include +#include + +int main(void) +{ + try + { + Webserv serv; + + serv.bind(80); + serv.listen(512); // 512 max connections arbitrary + serv.start(); + } + catch (std::exception& e) + { + std::cout << e.what() << '\n'; + } + return (0); +} + + +/* + wip hugo version + # include # include // errno # include // perror @@ -39,19 +69,17 @@ int main() perror("err bind(): "); return 0; } - /* - https://beej.us/guide/bgnet/html/index-wide.html#cb29 : - - Sometimes, you might notice, you try to rerun a server and bind() fails, claiming “Address already in use.” What does that mean? Well, a little bit of a socket that was connected is still hanging around in the kernel, and it’s hogging the port. You can either wait for it to clear (a minute or so), or add code to your program allowing it to reuse the port, like this: - - int yes=1; - - // lose the pesky "Address already in use" error message - if (setsockopt(listener,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof yes) == -1) { - perror("setsockopt"); - exit(1); - } - */ + // https://beej.us/guide/bgnet/html/index-wide.html#cb29 : + // + // Sometimes, you might notice, you try to rerun a server and bind() fails, claiming “Address already in use.” What does that mean? Well, a little bit of a socket that was connected is still hanging around in the kernel, and it’s hogging the port. You can either wait for it to clear (a minute or so), or add code to your program allowing it to reuse the port, like this: + // + // int yes=1; + // + // // lose the pesky "Address already in use" error message + // if (setsockopt(listener,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof yes) == -1) { + // perror("setsockopt"); + // exit(1); + // } lstn = listen(socket_fd, NB_CONX); if (lstn == INVALID_LSTN) @@ -70,4 +98,5 @@ int main() return 0; } +*/