예제 #1
0
	void HttpServer::newConnection(int fd, const net::Address& addr)
	{
		HttpClientHandler* handler = new HttpClientHandler(this,fd);
		connect(handler,SIGNAL(closed()),this,SLOT(slotConnectionClosed()));
		Out(SYS_WEB|LOG_NOTICE) << "connection from "<< addr.toString()  << endl;
		clients.append(handler);
	}
예제 #2
0
void TCPClient::sendData(const char* data, std::size_t size, const net::Address& peerAddress) 
{
	TraceL << "Send data to " << peerAddress << endl;

	// Ensure permissions exist for the peer.
	if (!hasPermission(peerAddress.host()))	
		throw std::runtime_error("No permission exists for peer: " + peerAddress.host());	

	auto conn = connections().get(peerAddress, nullptr);
	if (!conn)	
		throw std::runtime_error("No peer exists for: " + peerAddress.toString());
	
	conn->send(data, size);
}
예제 #3
0
	bool UTPServer::Private::bind(const net::Address& addr)
	{
		net::ServerSocket::Ptr sock(new net::ServerSocket(this));
		if (!sock->bind(addr))
		{
			return false;
		}
		else
		{
			Out(SYS_UTP | LOG_NOTICE) << "UTP: bound to " << addr.toString() << endl;
			sock->setTOS(tos);
			sock->setReadNotificationsEnabled(false);
			sock->setWriteNotificationsEnabled(false);
			sockets.append(sock);
			return true;
		}
	}