Add TCP socket prompt feature.
authorMikhail Kurinnoi <m.kurinnoi@samsung.com>
Mon, 4 Feb 2019 11:19:47 +0000 (14:19 +0300)
committerAlexander Soldatov/AI Ecosystem Lab /SRR/Staff Engineer/삼성전자 <soldatov.a@samsung.com>
Tue, 5 Feb 2019 10:22:34 +0000 (13:22 +0300)
Provide custom socket prompt string in order to check
send/receive capability of established connection.
Required by VS plugin.

README.md
src/config/configurationmanager.cpp
src/config/tracelogconfig.cpp
src/config/tracelogconfig.h
src/profiler.cpp
src/tracelog/tracelog.cpp
src/tracelog/tracelog.h

index f2cabc6c9ea1424f508c19dc3907b28a88314130..200aea35c9f49e86126172ab1b4f8639a5be6a07 100644 (file)
--- a/README.md
+++ b/README.md
@@ -237,6 +237,9 @@ dumped (only timestamp of execution and configuration parameters is stored).
   - `PROF_TRACE_SOCKET` - optional, defines port of the socket. `PROF_TRACE_STREAM`
     should be `Socket`. The default port is 6050.
 
+  - `PROF_TRACE_SOCKET_PROMPT` - optional, defines server prompt string.
+    `PROF_TRACE_STREAM` should be `Socket`.
+
 ### Control logging
 
   - `PROF_LOG_STREAM` - defines the output channel for log messages. Can be
index 33ee9f3285c612cc3bfef60d251849117f4dd541..85bec8e99a15542ba740dddf417dc4d4bb505f03 100644 (file)
@@ -126,6 +126,7 @@ void ConfigurationManager::FetchConfig(TraceLogConfig &config) const
     FetchValue("PROF_TRACE_STREAM", new_config.OutputStream);
 
     FetchValue("PROF_TRACE_SOCKET", new_config.SocketPort);
+    FetchValue("PROF_TRACE_SOCKET_PROMPT", new_config.SocketPrompt);
 
     // Apply changes to the current configuration.
     config = new_config;
index be280982d1242a435966f62d4d13408efa009314..278328dc7badbe32027fcf56e3670f61bb5453e0 100644 (file)
@@ -24,6 +24,7 @@ TraceLogConfig::TraceLogConfig()
     : OutputStream(TraceLogOutputStream::Stdout)
     , FileName()
     , SocketPort()
+    , SocketPrompt()
 {}
 
 void TraceLogConfig::Validate()
index 4f8d9aa46af19068e179e814b67a510a6d2e5a03..94de1ca379f17c907bc1deca23703501a118c99f 100644 (file)
@@ -60,6 +60,7 @@ struct TraceLogConfig
     //
 
     std::string SocketPort;
+    std::string SocketPrompt;
     static constexpr int MinAllowedSocketPort = 1;
     static constexpr int MaxAllowedSocketPort = 65535;
     static constexpr uint16_t DefaultSocketPort = 6050;
index a725c5e8c86c642e0c701b4adba0ef2c229afb57..aa1bdb4d467d2457faa0e4eddf229c2e13536977 100644 (file)
@@ -305,7 +305,7 @@ void Profiler::SetupTraceLog(TraceLogConfig &config)
             socket_port = static_cast<uint16_t>(stoi(config.SocketPort));
         }
         m_traceLog.reset(
-            ITraceLog::Create(ITraceLog::SocketStream, socket_port));
+            ITraceLog::Create(ITraceLog::SocketStream, socket_port, config.SocketPrompt));
     }
 }
 
index 0c59ef64ab4d2053a8015cb335ac4bc0497ead80..755152b9ee53b55a141dce4290efe63a43c1aa34 100644 (file)
@@ -64,7 +64,7 @@ public:
         }
     }
 
-    TraceLog(SocketStream_t, uint16_t port)
+    TraceLog(SocketStream_t, uint16_t port, const std::string &SocketPrompt)
         : m_stream(*new net::osocketstream())
         , m_stream_owner(true)
         , m_tracefmt(m_stream)
@@ -73,6 +73,10 @@ public:
         {
             m_stream.exceptions(std::ios::failbit | std::ios::badbit);
             static_cast<net::osocketstream&>(m_stream).start(port);
+            if (!SocketPrompt.empty())
+            {
+                m_stream << SocketPrompt << std::endl;
+            }
         }
         catch (...)
         {
@@ -454,7 +458,7 @@ ITraceLog *ITraceLog::Create(
 
 // static
 ITraceLog *ITraceLog::Create(
-    SocketStream_t SocketStream, uint16_t port)
+    SocketStream_t SocketStream, uint16_t port, const std::string &SocketPrompt)
 {
-    return new TraceLog(SocketStream, port);
+    return new TraceLog(SocketStream, port, SocketPrompt);
 }
index dbf9d8134739d1190e1906214c8b056bba67d5a2..a7b15edcd6375c4c58824becfe38617788e396ce 100644 (file)
@@ -63,7 +63,7 @@ public:
 
     static ITraceLog *Create(FileStream_t, const std::string &filename);
 
-    static ITraceLog *Create(SocketStream_t, uint16_t port);
+    static ITraceLog *Create(SocketStream_t, uint16_t port, const std::string &SocketPrompt);
 
     //
     // Profiler records