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


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

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


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

示例1: 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

示例2: methodGet

bool HttpServer::methodGet(SocketClient &client) {
	std::string htmlBody;
	std::string docType;
	int docTypeSize = 0;
	bool exitRequest = false;

	// Parse what to get
	if (StringConverter::isRootFile(client.getMessage())) {
		const std::string HTML_MOVED = "<html>\r\n"                            \
		                               "<head>\r\n"                            \
		                               "<title>Page is moved</title>\r\n"      \
		                               "</head>\r\n"                           \
		                               "<body>\r\n"                            \
		                               "<h1>Moved</h1>\r\n"                    \
		                               "<p>This page is moved:\r\n"            \
		                               "<a href=\"%s:%d%s\">link</a>.</p>\r\n" \
		                               "</body>\r\n"                           \
		                               "</html>";
		StringConverter::addFormattedString(docType, HTML_MOVED.c_str(), _interface.getIPAddress().c_str(), _properties.getHttpPort(), "/index.html");
		docTypeSize = docType.size();

		getHtmlBodyWithContent(htmlBody, HTML_MOVED_PERMA, "/index.html", CONTENT_TYPE_XML, docTypeSize, 0);
	} else {
		std::string file;
		if (StringConverter::hasTransportParameters(client.getMessage())) {
			processStreamingRequest(client);
		} else if (StringConverter::getRequestedFile(client.getMessage(), file)) {
			// remove first '/'
			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);
				}
//.........这里部分代码省略.........
开发者ID:arn354,项目名称:SATPI,代码行数:101,代码来源:HttpServer.cpp


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