tmp try with luke code
This commit is contained in:
@@ -1,4 +1,34 @@
|
||||
|
||||
/*
|
||||
luke version
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include <Webserv.hpp>
|
||||
|
||||
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 <iostream>
|
||||
# include <cerrno> // errno
|
||||
# include <cstdio> // 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;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user