-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservermain.cpp
More file actions
60 lines (44 loc) · 1.43 KB
/
servermain.cpp
File metadata and controls
60 lines (44 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "src/include/TCP_Server.h"
#include <iostream>
#include <cstdlib>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
// void sig_int_handler(int s)
// {
// std::cout << "Caught signal:" << s << std::endl;
// TCP_Server *server = TCP_Server::getInstance();
// if (server->new_socket != -1)
// {
// server->disconnect();
// }
// delete[] server->message;
// exit(1);
// }
// void handle_sig_int()
// {
// struct sigaction sigIntHandler;
// sigIntHandler.sa_handler = sig_int_handler;
// sigemptyset(&sigIntHandler.sa_mask);
// sigIntHandler.sa_flags = 0;
// sigaction(SIGINT, &sigIntHandler, NULL);
// }
int main()
{
// handle_sig_int();
std::cout << "Starting Server on port " << 8080 << std::endl;
TCP_Server *tcp_server = TCP_Server::getInstance();
// tcp_server->connect();
// std::string message = std::string(tcp_server->message);
// std::string response = message + " but from the server \r\n";
// do
// {
// std::cout << "responding with:" << tcp_server->message << std::endl;
// tcp_server->respond(tcp_server->message, std::string(tcp_server->message).length());
// std::cout << "responded" << std::endl;
// tcp_server->sockRead();
// message = std::string(tcp_server->message);
// } while (!tcp_server->isClosed() && message.length() != 0);
tcp_server->disconnect();
return 0;
}