1 #include <lib/network/serversocket.h>
3 bool eServerSocket::ok()
8 void eServerSocket::notifier(int)
10 int clientfd, clientlen;
11 struct sockaddr_in client_addr;
13 eDebug("[SERVERSOCKET] incoming connection!");
15 clientlen=sizeof(client_addr);
16 clientfd=accept(getDescriptor(),
17 (struct sockaddr *) &client_addr,
18 (socklen_t*)&clientlen);
20 eDebug("[SERVERSOCKET] error on accept()");
22 newConnection(clientfd);
25 eServerSocket::eServerSocket(int port, eMainloop *ml): eSocket(ml)
27 struct sockaddr_in serv_addr;
29 serv_addr.sin_family=AF_INET;
30 serv_addr.sin_addr.s_addr=INADDR_ANY;
31 serv_addr.sin_port=htons(port);
36 setsockopt(getDescriptor(), SOL_SOCKET, SO_REUSEADDR, &val, 4);
38 if(bind(getDescriptor(),
39 (struct sockaddr *) &serv_addr,
42 eDebug("[SERVERSOCKET] ERROR on bind() (%m)");
45 listen(getDescriptor(), 0);
47 rsn->setRequested(eSocketNotifier::Read);
50 eServerSocket::~eServerSocket()
53 eDebug("[SERVERSOCKET] destructed");