-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
34 lines (30 loc) · 811 Bytes
/
main.cpp
File metadata and controls
34 lines (30 loc) · 811 Bytes
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
//#include "server_socket.hpp"
#include "Server.hpp"
#include "client_socket.hpp"
template <typename T>
class handle: public SocketHandler<T>
{
public:
handle(unique_ptr<Socket<T>> sock): SocketHandler<T>(std::move(sock)){};
int handleRead()
{
SocketHandler<T>::handleRead();
std::cout<<this->read_data;
write("hello");
}
void write(string data)
{
this->write_data = data;
SocketHandler<T>::write();
}
};
int main()
{
Reactor *rec = Reactor::getInstance();
AsyncServer<inet_stream_addr, handle, ServerSocketHandler> server(8080);
// unique_ptr<client_sock_stream> cl(new client_sock_stream(80, "localhost"));
/*handle<client_sock_stream> hd(cl);
hd.write("hi"); */
rec->Run();
return 0;
}