namespace libt2n
{
+/** @brief create a new tcp-based server
+ @param port tcp port you want to listen on
+ @param ip the local ip you want to listen on. "0.0.0.0" means all local ips (default).
+*/
socket_server::socket_server(int port, const std::string& ip)
: server(), socket_handler(0,tcp_s)
{
// TODO
}
+/** @brief create a new unix-socked-based server
+ @param path path of the socket
+ @param filemode permissions you want to open the socket with
+ @param user local username for the socket
+ @param group local groupname for the socket
+*/
socket_server::socket_server(const std::string& path, mode_t filemode, const std::string& user, const std::string& group)
: server(), socket_handler(0,unix_s)
{
return;
}
-void socket_server::fill_buffer(long long usec_timeout)
+bool socket_server::fill_buffer(long long usec_timeout)
{
fd_set used_fdset=connection_set;
}
// check all connections for pending data
- fill_connection_buffers();
+ return fill_connection_buffers();
}
- return;
+ return false;
}
-void socket_server::fill_connection_buffers()
+bool socket_server::fill_connection_buffers()
{
+ bool data_found;
+
std::map<unsigned int, server_connection*>::iterator ie=connections.end();
for(std::map<unsigned int, server_connection*>::iterator i=connections.begin(); i != ie; i++)
if (!i->second->server_connection::is_closed())
- i->second->fill_buffer(0);
+ if (i->second->fill_buffer(0))
+ data_found=true;
+
+ return data_found;
}
void socket_server::remove_connection_socket(int sock)