From 272404a0c4b647d5f9e2d21bc2803025de07399d Mon Sep 17 00:00:00 2001 From: hugogogo Date: Wed, 13 Jul 2022 14:30:00 +0200 Subject: [PATCH] tmp try with luke code --- srcs/main.cpp | 55 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 13 deletions(-) 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; } +*/