not much more, trying a fork
This commit is contained in:
@@ -35,7 +35,6 @@ void Webserv::bind(in_port_t port)
|
|||||||
{
|
{
|
||||||
::perror("err bind(): ");
|
::perror("err bind(): ");
|
||||||
throw std::runtime_error("Socket bind");
|
throw std::runtime_error("Socket bind");
|
||||||
// std::cerr << "error bind\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
luke version
|
luke version
|
||||||
*/
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
@@ -25,16 +24,19 @@ int main(void)
|
|||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
wip hugo version
|
wip hugo version
|
||||||
|
*/
|
||||||
# include <map>
|
# include <map>
|
||||||
# include <exception>
|
# include <exception>
|
||||||
# include <stdexcept>
|
# include <stdexcept>
|
||||||
# include <unistd.h> // close
|
|
||||||
# include <fcntl.h> // fcntl
|
# include <fcntl.h> // fcntl
|
||||||
|
|
||||||
|
# include <unistd.h> // close
|
||||||
|
# include <stdlib.h> // exit
|
||||||
# include <iostream> // cout, cin
|
# include <iostream> // cout, cin
|
||||||
# include <cerrno> // errno
|
# include <cerrno> // errno
|
||||||
# include <cstdio> // perror
|
# include <cstdio> // perror
|
||||||
@@ -45,8 +47,9 @@ int main(void)
|
|||||||
# include <poll.h> // poll
|
# include <poll.h> // poll
|
||||||
|
|
||||||
# define INVALID -1
|
# define INVALID -1
|
||||||
# define PORT 1025
|
|
||||||
# define BACKLOG 20
|
# define BACKLOG 20
|
||||||
|
// test with curl http://localhost:PORT (replace PORT by the port number you choose below)
|
||||||
|
# define PORT 4040
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@@ -114,10 +117,19 @@ int main()
|
|||||||
std::cout << "server accepted a socket from: "
|
std::cout << "server accepted a socket from: "
|
||||||
<< inet_ntoa(their_addr.sin_addr)
|
<< inet_ntoa(their_addr.sin_addr)
|
||||||
<< "\n";
|
<< "\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;
|
return 0;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user