Exemplo n.º 1
0
void SocketLibEvent::write(const char* data, size_t data_len) {
	if (closing_) return;

	auto output = bufferevent_get_output(bev_);
	auto retval = evbuffer_add(output, data, data_len);

	if (retval != 0) {
		onSocketClose(true);
		return;
	}

	if (evbuffer_get_length(output) > MAX_OUTPUT_BUFFER_SIZE) {
        /* LogApiSock("WsApiEnviar MAX_OUTPUT_BUFFER_SIZE"); */
        onSocketClose(true);
		return;
	}
}
Exemplo n.º 2
0
void SocketLibEvent::closeReal() {
	if (closed_) return;
    closed_ = true;

	auto sel = sl_->sev;
	if (sel) {
		sel->onSocketClose(this);
	}

	sp_->freeSocketIndex(getId());

	if (bev_) {
		/* FIXME: Gracefully shutdown(fd, SHUT_WR) the socket, unless forced or destroyed. */
		/* evutil_closesocket(fd_); */
		bufferevent_free(bev_);
		bev_ = nullptr;
	}
}
Exemplo n.º 3
0
void TCPSocket::onClose() 
{        
    TraceLS(this) << "On close" << endl;    
    onSocketClose();
}
Exemplo n.º 4
0
void UDPSocket::onClose() 
{        
    ErrorS(this) << "On close" << endl;    
    //emitClose();
    onSocketClose();
}