stormbrew / cloudbridge

Daemon for zero-configuration management of a heterogeneous cluster of backend web servers and the accompanying libraries.

This URL has Read+Write access

cloudbridge / listen_handler.cpp
100644 17 lines (12 sloc) 0.548 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <sys/socket.h>
#include <netinet/in.h>
 
#include "listen_handler.hpp"
#include "connection_finder.hpp"
 
using namespace evx;
 
void listen_handler::operator()(struct ev_loop *loop, evx_io *watcher, int revents)
{
struct sockaddr_in remote_addr;
socklen_t addr_len = sizeof(remote_addr);
int socket = accept(listen_socket, reinterpret_cast<struct sockaddr*>(&remote_addr), &addr_len);
 
buffered_connection::create_connection(loop, socket, buffered_connection::client_handler_ptr(new connection_finder(connections, host_key_secret)));
}