not much more, trying a fork

This commit is contained in:
hugogogo
2022-07-16 18:55:45 +02:00
parent ca81b6760e
commit 726bf36b17
3 changed files with 17 additions and 6 deletions

View File

@@ -35,7 +35,6 @@ void Webserv::bind(in_port_t port)
{
::perror("err bind(): ");
throw std::runtime_error("Socket bind");
// std::cerr << "error bind\n";
}
}

View File

@@ -1,7 +1,6 @@
/*
luke version
*/
#include <iostream>
#include <exception>
@@ -25,16 +24,19 @@ int main(void)
}
return (0);
}
*/
/*
wip hugo version
*/
# include <map>
# include <exception>
# include <stdexcept>
# include <unistd.h> // close
# include <fcntl.h> // fcntl
# include <unistd.h> // close
# include <stdlib.h> // exit
# include <iostream> // cout, cin
# include <cerrno> // errno
# include <cstdio> // perror
@@ -45,8 +47,9 @@ int main(void)
# include <poll.h> // poll
# define INVALID -1
# define PORT 1025
# define BACKLOG 20
// test with curl http://localhost:PORT (replace PORT by the port number you choose below)
# define PORT 4040
int main()
{
@@ -114,10 +117,19 @@ int main()
std::cout << "server accepted a socket from: "
<< inet_ntoa(their_addr.sin_addr)
<< "\n";
break;
// // with a fork
// if (!fork()) // child process
// {
// close(sckt_fd); // child doesn't need the listener
// if (send(axpt_fd, "hello world !", 13, 0) == INVALID)
// perror("err send(): ");
// close(axpt_fd);
// exit(0);
// }
// close(axpt_fd); // parent doesn't need this
}
return 0;
}
*/

BIN
webserv

Binary file not shown.