예제 #1
0
	void thread_send() {
		while (connected.load()) {
			spmsg_t msg;
			send_queue.pop(msg, true);
			if (!msg)
				continue;

			const char* buffer = (const char*)msg->data();
			uint32_t remain = msg->size();
			uint32_t len = 0;
			uint32_t pos = 0;
			do {
				len = ::send(this->sock, buffer+pos, remain, 0);
				if (len <= 0) {
					printf("send error %d\n", get_errno());
					return;
				}
				pos += len;
				remain -= len;
			} while (remain > 0);
		}
	}
예제 #2
0
	spmsg_t recv(bool wait_ = false) {
		spmsg_t msg;
		recv_queue.pop(msg, wait_);
		return msg;
	}