当前位置: 首页>>代码示例>>C++>>正文


C++ SocketClient::getFD方法代码示例

本文整理汇总了C++中SocketClient::getFD方法的典型用法代码示例。如果您正苦于以下问题:C++ SocketClient::getFD方法的具体用法?C++ SocketClient::getFD怎么用?C++ SocketClient::getFD使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SocketClient的用法示例。


在下文中一共展示了SocketClient::getFD方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: methodPost

bool HttpServer::methodPost(const SocketClient &client) {
	std::string content;
	if (StringConverter::getContentFrom(client.getMessage(), content)) {
		std::string file;
		if (StringConverter::getRequestedFile(client.getMessage(), file)) {
			if (file.compare("/data.xml") == 0) {
				// not used yet
			} else if (file.compare("/streams.xml") == 0) {
				_streams.fromXML(content);
			} else if (file.compare("/config.xml") == 0) {
				_properties.fromXML(content);
#ifdef LIBDVBCSA
			} else if (file.compare("/dvbapi.xml") == 0) {
				_streams.getDecrypt()->fromXML(content);
#endif
			}
		}
	}
	// setup reply
	std::string htmlBody;
	getHtmlBodyWithContent(htmlBody, HTML_NO_RESPONSE, "", CONTENT_TYPE_HTML, 0, 0);

	// send 'htmlBody' to client
	if (send(client.getFD(), htmlBody.c_str(), htmlBody.size(), 0) == -1) {
		PERROR("send htmlBody");
		return false;
	}
	return true;
}
开发者ID:arn354,项目名称:SATPI,代码行数:29,代码来源:HttpServer.cpp

示例2: copySocketClientAttr

void StreamClient::copySocketClientAttr(const SocketClient &socket) {
	_rtspFD = socket.getFD();
	_ip_addr = socket.getIPAddress();
	_rtspMsg = socket.getMessage().c_str();
}
开发者ID:crowm,项目名称:SATPI,代码行数:5,代码来源:StreamClient.cpp

示例3: methodGet


//.........这里部分代码省略.........
			file.erase(0, 1);

			const std::string filePath = _properties.getWebPath() + "/" + file;
			if (file.compare("data.xml") == 0) {
				makeDataXML(docType);
				docTypeSize = docType.size();

				getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_XML, docTypeSize, 0);
			} else if (file.compare("streams.xml") == 0) {
				makeStreamsXML(docType);
				docTypeSize = docType.size();

				getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_XML, docTypeSize, 0);
			} else if (file.compare(_properties.getFileName()) == 0) {
				_properties.addToXML(docType);
				docTypeSize = docType.size();

				getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_XML, docTypeSize, 0);
#ifdef LIBDVBCSA
			} else if (file.compare(_streams.getDecrypt()->getFileName()) == 0) {
				_streams.getDecrypt()->addToXML(docType);
				docTypeSize = docType.size();

				getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_XML, docTypeSize, 0);
#endif
			} else if (file.compare("log.xml") == 0) {
				docType = make_log_xml();
				docTypeSize = docType.size();

				getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_XML, docTypeSize, 0);
			} else if (file.compare("STOP") == 0) {
				exitRequest = true;

				getHtmlBodyWithContent(htmlBody, HTML_NO_RESPONSE, "", CONTENT_TYPE_HTML, 0, 0);
			} else if ((docTypeSize = readFile(filePath.c_str(), docType))) {
				if (file.find(".xml") != std::string::npos) {
					// check if the request is the SAT>IP description xml then fill in the server version, UUID and tuner string
					if (docType.find("urn:ses-com:device") != std::string::npos) {
						SI_LOG_DEBUG("Client: %s requesed %s", client.getIPAddress().c_str(), file.c_str());
						// check did we get our desc.xml (we assume there are some %s in there)
						if (docType.find("%s") != std::string::npos) {
							docTypeSize -= 4 * 2; // minus 4x %s
							docTypeSize += _properties.getDeliverySystemString().size();
							docTypeSize += _properties.getUUID().size();
							docTypeSize += _properties.getSoftwareVersion().size();
							docTypeSize += _properties.getXSatipM3U().size();
							char *doc_desc_xml = new char[docTypeSize + 1];
							if (doc_desc_xml != nullptr) {
								snprintf(doc_desc_xml, docTypeSize + 1, docType.c_str(), _properties.getSoftwareVersion().c_str(),
								         _properties.getUUID().c_str(), _properties.getDeliverySystemString().c_str(),
								         _properties.getXSatipM3U().c_str());
								docType = doc_desc_xml;
								DELETE_ARRAY(doc_desc_xml);
							}
						}
					}
					getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_XML, docTypeSize, 0);

				} else if (file.find(".html") != std::string::npos) {
					getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_HTML, docTypeSize, 0);
				} else if (file.find(".js") != std::string::npos) {
					getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_JS, docTypeSize, 0);
				} else if (file.find(".css") != std::string::npos) {
					getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_CSS, docTypeSize, 0);
				} else if (file.find(".m3u") != std::string::npos) {
					getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_VIDEO, docTypeSize, 0);
				} else if ((file.find(".png") != std::string::npos) ||
				           (file.find(".ico") != std::string::npos)) {
					getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_PNG, docTypeSize, 0);
				} else {
					getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_HTML, docTypeSize, 0);
				}
			} else {
				file = _properties.getWebPath() + "/" + "404.html";
				docTypeSize = readFile(file.c_str(), docType);
				getHtmlBodyWithContent(htmlBody, HTML_NOT_FOUND, file, CONTENT_TYPE_HTML, docTypeSize, 0);
			}
		}
	}
	// send something?
	if (docType.size() > 0) {
//		SI_LOG_INFO("%s", htmlBody);
		// send 'htmlBody' to client
		if (send(client.getFD(), htmlBody.c_str(), htmlBody.size(), 0) == -1) {
			PERROR("send htmlBody");
			return false;
		}
		// send 'docType' to client
		if (send(client.getFD(), docType.c_str(), docTypeSize, 0) == -1) {
			PERROR("send docType");
			return false;
		}
		return true;
	}
	// check did we have stop request
	if (exitRequest) {
		_properties.setExitApplication();
	}
	return false;
}
开发者ID:arn354,项目名称:SATPI,代码行数:101,代码来源:HttpServer.cpp


注:本文中的SocketClient::getFD方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。