    

 ## On this page

  

 

 # test\_dvs\_server

 Last update: 16.07.2025 

[Go to the documentation of this file.](test__dvs__server_8cpp.xhtml)<a id="l00001" name="l00001"></a> 1/\* \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

<a id="l00002" name="l00002"></a> 2 \* Copyright 2017-2023 ANSYS, Inc.

<a id="l00003" name="l00003"></a> 3 \* All Rights Reserved.

<a id="l00004" name="l00004"></a> 4 \*

<a id="l00005" name="l00005"></a> 5 \* Restricted Rights Legend

<a id="l00006" name="l00006"></a> 6 \*

<a id="l00007" name="l00007"></a> 7 \* Use, duplication, or disclosure of this

<a id="l00008" name="l00008"></a> 8 \* software and its documentation by the

<a id="l00009" name="l00009"></a> 9 \* Government is subject to restrictions as

<a id="l00010" name="l00010"></a> 10 \* set forth in subdivision \[(b)(3)(ii)\] of

<a id="l00011" name="l00011"></a> 11 \* the Rights in Technical Data and Computer

<a id="l00012" name="l00012"></a> 12 \* Software clause at 52.227-7013.

<a id="l00013" name="l00013"></a> 13 \* \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

<a id="l00014" name="l00014"></a> 14 \*/

<a id="l00015" name="l00015"></a> 15 

<a id="l00029" name="l00029"></a> 29\#include &lt;stdio.h&gt;

<a id="l00030" name="l00030"></a> 30\#include &lt;stdlib.h&gt;

<a id="l00031" name="l00031"></a> 31\#include &lt;string.h&gt;

<a id="l00032" name="l00032"></a> 32\#include &lt;stdint.h&gt;

<a id="l00033" name="l00033"></a> 33\#include &lt;stdarg.h&gt;

<a id="l00034" name="l00034"></a> 34 

<a id="l00035" name="l00035"></a> 35\#include "[dvs\_server\_interface.h](dvs__server__interface_8h.xhtml)"

<a id="l00036" name="l00036"></a> 36\#include "[dynamic\_visualization\_store\_enums.h](dynamic__visualization__store__enums_8h.xhtml)"

<a id="l00037" name="l00037"></a> 37\#include "logger.h"

<a id="l00038" name="l00038"></a> 38 

<a id="l00039" name="l00039"></a> 39\#include &lt;atomic&gt;

<a id="l00040" name="l00040"></a> 40\#include &lt;chrono&gt;

<a id="l00041" name="l00041"></a> 41\#include &lt;mutex&gt;

<a id="l00042" name="l00042"></a> 42\#include &lt;thread&gt;

<a id="l00043" name="l00043"></a> 43\#include &lt;vector&gt;

<a id="l00044" name="l00044"></a> 44\#include &lt;signal.h&gt;

<a id="l00045" name="l00045"></a> 45 

<a id="l00046" name="l00046"></a> 46static std::atomic&lt;bool&gt; s_terminate{false};

<a id="l00047" name="l00047"></a> 47static std::mutex s_server_mutex;

<a id="l00048" name="l00048"></a> 48static [DVS::IServer](class_d_v_s_1_1_i_server.xhtml)* s_server{nullptr};

<a id="l00049" name="l00049"></a> 49 

<a id="l00055" name="l00055"></a>[ 55](test__dvs__server_8cpp.xhtml#a89a8322bea357674e81ba9cbdefe0378)void [signal\_callback\_handler](test__dvs__server_8cpp.xhtml#a89a8322bea357674e81ba9cbdefe0378)(int signum)

<a id="l00056" name="l00056"></a> 56{

<a id="l00057" name="l00057"></a> 57 fprintf(stdout, "Caught Signal: %i\\n", signum);

<a id="l00058" name="l00058"></a> 58 s_terminate = true;

<a id="l00059" name="l00059"></a> 59 std::lock_guard&lt;std::mutex&gt; lock(s_server_mutex);

<a id="l00060" name="l00060"></a> 60 if (s_server)

<a id="l00061" name="l00061"></a> 61 {

<a id="l00062" name="l00062"></a> 62 s_server-&gt;[terminating](class_d_v_s_1_1_i_server.xhtml#a6cb1f69ad4b9213dde48d4cd5b3f2111)();

<a id="l00063" name="l00063"></a> 63 }

<a id="l00064" name="l00064"></a> 64}

<a id="l00065" name="l00065"></a> 65 

<a id="l00073" name="l00073"></a>[ 73](test__dvs__server_8cpp.xhtml#a3c04138a5bfe5d72780bb7e82a18e627)int [main](test__dvs__server_8cpp.xhtml#a3c04138a5bfe5d72780bb7e82a18e627)(int argc, char** argv)

<a id="l00074" name="l00074"></a> 74{

<a id="l00075" name="l00075"></a> 75 //Register a signal handler instead of just killing the app so

<a id="l00076" name="l00076"></a> 76 //we can shutdown gracefully

<a id="l00077" name="l00077"></a> 77 signal(SIGINT, [signal\_callback\_handler](test__dvs__server_8cpp.xhtml#a89a8322bea357674e81ba9cbdefe0378));

<a id="l00078" name="l00078"></a> 78 

<a id="l00079" name="l00079"></a> 79 uint32_t port = 50055;

<a id="l00080" name="l00080"></a> 80 uint32_t delay_ms = 500;

<a id="l00081" name="l00081"></a> 81 char host[512] = {0};

<a id="l00082" name="l00082"></a> 82 strcpy(host, "127.0.0.1");

<a id="l00083" name="l00083"></a> 83 char protocol[10] = {0};

<a id="l00084" name="l00084"></a> 84 strcpy(protocol, "grpc");

<a id="l00085" name="l00085"></a> 85 

<a id="l00086" name="l00086"></a> 86 char secret[255] = {0};

<a id="l00087" name="l00087"></a> 87 char cache_uri[512] = {0};

<a id="l00088" name="l00088"></a> 88 char dvs_file_loc[1024] = {0};

<a id="l00089" name="l00089"></a> 89 uint32_t debug_wait_sec = 0;

<a id="l00090" name="l00090"></a> 90 uint32_t server_number = 0;

<a id="l00091" name="l00091"></a> 91 uint32_t local_ranks = 1;

<a id="l00092" name="l00092"></a> 92 uint32_t server_verbosity = 3;

<a id="l00093" name="l00093"></a> 93 uint32_t timeout_sec = 15;

<a id="l00094" name="l00094"></a> 94 

<a id="l00095" name="l00095"></a> 95 uint32_t i = 1;

<a id="l00096" name="l00096"></a> 96 while (i &lt; argc)

<a id="l00097" name="l00097"></a> 97 {

<a id="l00098" name="l00098"></a> 98 if ((strcmp(argv[i], "-p") == 0 ) &amp;&amp; (i &lt; argc - 1))

<a id="l00099" name="l00099"></a> 99 {

<a id="l00100" name="l00100"></a> 100 i++;

<a id="l00101" name="l00101"></a> 101 port = atoi(argv[i]);

<a id="l00102" name="l00102"></a> 102 }

<a id="l00103" name="l00103"></a> 103 else if ((strcmp(argv[i], "-h") == 0) &amp;&amp; (i &lt; argc - 1))

<a id="l00104" name="l00104"></a> 104 {

<a id="l00105" name="l00105"></a> 105 i++;

<a id="l00106" name="l00106"></a> 106 strncpy(host, argv[i], 255);

<a id="l00107" name="l00107"></a> 107 }

<a id="l00108" name="l00108"></a> 108 else if ((strcmp(argv[i], "-protocol") == 0) &amp;&amp; (i &lt; argc - 1))

<a id="l00109" name="l00109"></a> 109 {

<a id="l00110" name="l00110"></a> 110 i++;

<a id="l00111" name="l00111"></a> 111 strncpy(protocol, argv[i], 10);

<a id="l00112" name="l00112"></a> 112 if (strcmp(protocol, "grpc") != 0 &amp;&amp; strcmp(protocol, "null") != 0 )

<a id="l00113" name="l00113"></a> 113 {

<a id="l00114" name="l00114"></a> 114 fprintf(stderr, "protocol: %s invalid\\n", protocol);

<a id="l00115" name="l00115"></a> 115 exit(1);

<a id="l00116" name="l00116"></a> 116 }

<a id="l00117" name="l00117"></a> 117 }

<a id="l00118" name="l00118"></a> 118 else if ((strcmp(argv[i], "-d") == 0) &amp;&amp; (i &lt; argc - 1))

<a id="l00119" name="l00119"></a> 119 {

<a id="l00120" name="l00120"></a> 120 i++;

<a id="l00121" name="l00121"></a> 121 delay_ms = atoi(argv[i]);

<a id="l00122" name="l00122"></a> 122 }

<a id="l00123" name="l00123"></a> 123 else if (strcmp(argv[i], "-secret") == 0)

<a id="l00124" name="l00124"></a> 124 {

<a id="l00125" name="l00125"></a> 125 i++;

<a id="l00126" name="l00126"></a> 126 strncpy(secret, argv[i], 255);

<a id="l00127" name="l00127"></a> 127 }

<a id="l00128" name="l00128"></a> 128 else if (strcmp(argv[i], "-server") == 0 &amp;&amp; (i &lt; argc - 3))

<a id="l00129" name="l00129"></a> 129 {

<a id="l00130" name="l00130"></a> 130 i++;

<a id="l00131" name="l00131"></a> 131 server_number = atoi(argv[i++]);

<a id="l00132" name="l00132"></a> 132 local_ranks = atoi(argv[i++]);

<a id="l00133" name="l00133"></a> 133 server_verbosity = atoi(argv[i]);

<a id="l00134" name="l00134"></a> 134 }

<a id="l00135" name="l00135"></a> 135 else if (strcmp(argv[i], "-cache\_uri") == 0)

<a id="l00136" name="l00136"></a> 136 {

<a id="l00137" name="l00137"></a> 137 i++;

<a id="l00138" name="l00138"></a> 138 strncpy(cache_uri, argv[i], 512);

<a id="l00139" name="l00139"></a> 139 }

<a id="l00140" name="l00140"></a> 140 else if (strcmp(argv[i], "-debug\_wait") == 0)

<a id="l00141" name="l00141"></a> 141 {

<a id="l00142" name="l00142"></a> 142 i++;

<a id="l00143" name="l00143"></a> 143 debug_wait_sec = atoi(argv[i]);

<a id="l00144" name="l00144"></a> 144 }

<a id="l00145" name="l00145"></a> 145 else if (strcmp(argv[i], "-timeout") == 0)

<a id="l00146" name="l00146"></a> 146 {

<a id="l00147" name="l00147"></a> 147 i++;

<a id="l00148" name="l00148"></a> 148 timeout_sec = atoi(argv[i]);

<a id="l00149" name="l00149"></a> 149 }

<a id="l00150" name="l00150"></a> 150 else if (strcmp(argv[i], "-dvs\_file") == 0)

<a id="l00151" name="l00151"></a> 151 {

<a id="l00152" name="l00152"></a> 152 i++;

<a id="l00153" name="l00153"></a> 153 strncpy(dvs_file_loc, argv[i], sizeof(dvs_file_loc)-1);

<a id="l00154" name="l00154"></a> 154 }

<a id="l00155" name="l00155"></a> 155 else

<a id="l00156" name="l00156"></a> 156 {

<a id="l00157" name="l00157"></a> 157 fprintf(stderr, "Unknown option: %s\\n", argv[i]);

<a id="l00158" name="l00158"></a> 158 fprintf(stderr, "Usage: %s \[-p port\] \[-h host\] \[-d ms delay\] \[-s dx dy dz\] \\n", argv[0]);

<a id="l00159" name="l00159"></a> 159 fprintf(stderr, "Options:\\n");

<a id="l00160" name="l00160"></a> 160 fprintf(stderr, " -p port Server port to connect to. Default: %u\\n", port);

<a id="l00161" name="l00161"></a> 161 fprintf(stderr, " -h host Server hostname to connect to. Default: %s\\n", host);

<a id="l00162" name="l00162"></a> 162 fprintf(stderr, " -protocol str Server protocol. I.E. grpc or null. Default: grpc");

<a id="l00163" name="l00163"></a> 163 fprintf(stderr, " -d delay(ms) Milliseconds to delay between server updates. Default: %u\\n", delay_ms);

<a id="l00164" name="l00164"></a> 164 fprintf(stderr, " -secret string Shared secret to use when talking with server Default: no shared secret\\n");

<a id="l00165" name="l00165"></a> 165 fprintf(stderr, " -server n r v Start a server using server number \[n\], expecting \[r\] local ranks for DVS connections to connect to with verbosity \[v\]. Local Rank Min/Max: 1/1000\\n");

<a id="l00166" name="l00166"></a> 166 fprintf(stderr, " -cache\_uri str The URI for the server to use for the cache. Default: No cache\\n");

<a id="l00167" name="l00167"></a> 167 fprintf(stderr, " -dvs\_file str Set a location for the dvs files to be created Default: ./\\n");

<a id="l00168" name="l00168"></a> 168 fprintf(stderr, " -timeout sec Shutdown the server if no new data has been received within timeout. Default: %u sec\\n", timeout_sec);

<a id="l00169" name="l00169"></a> 169 fprintf(stderr, " -debug\_wait s Wait for \[s\] for debugging\\n");

<a id="l00170" name="l00170"></a> 170 exit(1);

<a id="l00171" name="l00171"></a> 171 }

<a id="l00172" name="l00172"></a> 172 i++;

<a id="l00173" name="l00173"></a> 173 }

<a id="l00174" name="l00174"></a> 174 

<a id="l00175" name="l00175"></a> 175 //This is just used for debugging/attaching to the app if some problem arises

<a id="l00176" name="l00176"></a> 176 if (debug_wait_sec &gt; 0) {

<a id="l00177" name="l00177"></a> 177 std::this_thread::sleep_for(std::chrono::seconds(debug_wait_sec));

<a id="l00178" name="l00178"></a> 178 }

<a id="l00179" name="l00179"></a> 179 

<a id="l00180" name="l00180"></a> 180 char uri[512] = {0};

<a id="l00181" name="l00181"></a> 181 sprintf(uri, "%s://%s:%u", protocol, host, port);

<a id="l00182" name="l00182"></a> 182 //The server URI is used to setup the protocol host and port of the server

<a id="l00183" name="l00183"></a> 183 //(where and how clients need to connect). It will be something like:

<a id="l00184" name="l00184"></a> 184 //grpc:://localhost:50055

<a id="l00185" name="l00185"></a> 185 fprintf(stderr, "Server URI: %s\\n", uri);

<a id="l00186" name="l00186"></a> 186 fprintf(stderr, "Update Delay(ms): %u\\n", delay_ms);

<a id="l00187" name="l00187"></a> 187 

<a id="l00188" name="l00188"></a> 188 {

<a id="l00189" name="l00189"></a> 189 std::lock_guard&lt;std::mutex&gt; lock(s_server_mutex);

<a id="l00190" name="l00190"></a> 190 s_server = DVS::CREATE_SERVER_INSTANCE(uri);

<a id="l00191" name="l00191"></a> 191 }

<a id="l00192" name="l00192"></a> 192 if (s_server == nullptr)

<a id="l00193" name="l00193"></a> 193 {

<a id="l00194" name="l00194"></a> 194 fprintf(stderr, "Failed to create server\\n");

<a id="l00195" name="l00195"></a> 195 exit(1);

<a id="l00196" name="l00196"></a> 196 }

<a id="l00197" name="l00197"></a> 197 char temp[10];

<a id="l00198" name="l00198"></a> 198 snprintf(temp, 10, "%u", server_verbosity);

<a id="l00199" name="l00199"></a> 199 s_server-&gt;[set\_option](class_d_v_s_1_1_i_server.xhtml#a1edb4dec67086f10bc0329b6adf9084c)("VERBOSE",temp);

<a id="l00200" name="l00200"></a> 200 if (strlen(cache_uri) &gt; 0)

<a id="l00201" name="l00201"></a> 201 {

<a id="l00202" name="l00202"></a> 202 //If not using a cache\_uri the cache will be all in memory, not

<a id="l00203" name="l00203"></a> 203 //really useful for this specific test server app but showing a simple example.

<a id="l00204" name="l00204"></a> 204 //In the future you will be able to use the DVS Reader API to read data from

<a id="l00205" name="l00205"></a> 205 //memory using this instead of needing to read data from the cache.

<a id="l00206" name="l00206"></a> 206 

<a id="l00207" name="l00207"></a> 207 //The cache URI should be something like: hdf5://localhost/D:/my\_cache

<a id="l00208" name="l00208"></a> 208 s_server-&gt;[set\_option](class_d_v_s_1_1_i_server.xhtml#a1edb4dec67086f10bc0329b6adf9084c)("CACHE\_URI",cache_uri);

<a id="l00209" name="l00209"></a> 209 }

<a id="l00210" name="l00210"></a> 210 

<a id="l00211" name="l00211"></a> 211 if (strlen(dvs_file_loc) &gt; 0)

<a id="l00212" name="l00212"></a> 212 {

<a id="l00213" name="l00213"></a> 213 //The DVS file location let's you point the location of the auto created

<a id="l00214" name="l00214"></a> 214 //.dvs files to another location, absolute or relative to the cache\_uri location

<a id="l00215" name="l00215"></a> 215 s_server-&gt;[set\_option](class_d_v_s_1_1_i_server.xhtml#a1edb4dec67086f10bc0329b6adf9084c)("DVS\_FILE\_LOCATION", dvs_file_loc);

<a id="l00216" name="l00216"></a> 216 }

<a id="l00217" name="l00217"></a> 217 

<a id="l00218" name="l00218"></a> 218 if (strlen(secret) &gt; 0)

<a id="l00219" name="l00219"></a> 219 {

<a id="l00220" name="l00220"></a> 220 //This is needed if wanting to use a simple secret to allow clients

<a id="l00221" name="l00221"></a> 221 //to connect to you. The clients will also need this secret.

<a id="l00222" name="l00222"></a> 222 s_server-&gt;[set\_option](class_d_v_s_1_1_i_server.xhtml#a1edb4dec67086f10bc0329b6adf9084c)("SERVER\_SECURITY\_SECRET", secret);

<a id="l00223" name="l00223"></a> 223 }

<a id="l00224" name="l00224"></a> 224 

<a id="l00225" name="l00225"></a> 225 //The startup\_unthreaded call will start/initialize the server and block until

<a id="l00226" name="l00226"></a> 226 //a all clients have initialized the dataset and sent a single timestep. A call

<a id="l00227" name="l00227"></a> 227 //to s\_server-&gt;terminating() can be seen above in the signal handler to allow you

<a id="l00228" name="l00228"></a> 228 //to exit this call early.

<a id="l00229" name="l00229"></a> 229 s_server-&gt;[startup\_unthreaded](class_d_v_s_1_1_i_server.xhtml#ac61ce2698eec1adb521bbbf60cb78756)(server_number, local_ranks);

<a id="l00230" name="l00230"></a> 230 uint32_t size;

<a id="l00231" name="l00231"></a> 231 auto _uri = s_server-&gt;[get\_uri](class_d_v_s_1_1_i_server.xhtml#a087c3fed77651e0f62d7189f44a32443)();

<a id="l00232" name="l00232"></a> 232 if (_uri){

<a id="l00233" name="l00233"></a> 233 fprintf(stderr, "Actual Server URI: %s\\n", _uri);

<a id="l00234" name="l00234"></a> 234 }

<a id="l00235" name="l00235"></a> 235 //For this example we are going to quit early if number pending or number complete have not

<a id="l00236" name="l00236"></a> 236 //changed within timeout\_sec seconds.

<a id="l00237" name="l00237"></a> 237 uint32_t num_pending = 0;

<a id="l00238" name="l00238"></a> 238 uint32_t num_complete = 0;

<a id="l00239" name="l00239"></a> 239 auto start_time = std::chrono::system_clock::now();

<a id="l00240" name="l00240"></a> 240 

<a id="l00241" name="l00241"></a> 241 while (!s_terminate) {

<a id="l00242" name="l00242"></a> 242 //This is the main control loop of the server. DVS::IServer::update() just

<a id="l00243" name="l00243"></a> 243 //needs to be called in a loop to handle the server state until the server

<a id="l00244" name="l00244"></a> 244 //should be terminated.

<a id="l00245" name="l00245"></a> 245 //Note: update() will flush data to the cache so shutting down / exiting mid

<a id="l00246" name="l00246"></a> 246 //update will likely cause cache corruption.

<a id="l00247" name="l00247"></a> 247 [dvs\_ret](dynamic__visualization__store__error__codes_8h.xhtml#a1d7466ae72e89fe36cbf2408b4f7d9c1) ret_val = s_server-&gt;[update](class_d_v_s_1_1_i_server.xhtml#add6fcb530763dc217f5b3c17b25093c0)();

<a id="l00248" name="l00248"></a> 248 // Avoid burning up a CPU waiting for the I/O to complete

<a id="l00249" name="l00249"></a> 249 std::this_thread::sleep_for(std::chrono::milliseconds(delay_ms));

<a id="l00250" name="l00250"></a> 250 

<a id="l00251" name="l00251"></a> 251 uint32_t cur_num_pending = 0;

<a id="l00252" name="l00252"></a> 252 uint32_t cur_num_complete = 0;

<a id="l00253" name="l00253"></a> 253 s_server-&gt;[get\_timestep\_count](class_d_v_s_1_1_i_server.xhtml#a8a5339f222bcd46b06c2fa9a474b2c37)(cur_num_pending, cur_num_complete);

<a id="l00254" name="l00254"></a> 254 if (cur_num_pending == num_pending &amp;&amp; cur_num_complete == num_complete) {

<a id="l00255" name="l00255"></a> 255 //If our values haven't changed check to see if we should time out

<a id="l00256" name="l00256"></a> 256 std::chrono::duration&lt;double&gt; elapsed_seconds = std::chrono::system_clock::now() - start_time;

<a id="l00257" name="l00257"></a> 257 if (elapsed_seconds.count() &gt; timeout_sec) {

<a id="l00258" name="l00258"></a> 258 //Terminate the server and quit out

<a id="l00259" name="l00259"></a> 259 s_server-&gt;[terminating](class_d_v_s_1_1_i_server.xhtml#a6cb1f69ad4b9213dde48d4cd5b3f2111)();

<a id="l00260" name="l00260"></a> 260 s_terminate = true;

<a id="l00261" name="l00261"></a> 261 }

<a id="l00262" name="l00262"></a> 262 }

<a id="l00263" name="l00263"></a> 263 else {

<a id="l00264" name="l00264"></a> 264 //We are different so reset our counters

<a id="l00265" name="l00265"></a> 265 start_time = std::chrono::system_clock::now();

<a id="l00266" name="l00266"></a> 266 num_pending = cur_num_pending;

<a id="l00267" name="l00267"></a> 267 num_complete = cur_num_complete;

<a id="l00268" name="l00268"></a> 268 }

<a id="l00269" name="l00269"></a> 269 }

<a id="l00270" name="l00270"></a> 270 

<a id="l00271" name="l00271"></a> 271 num_pending = 1;

<a id="l00272" name="l00272"></a> 272 num_complete = 0;

<a id="l00273" name="l00273"></a> 273 while (num_pending &gt; 0) {

<a id="l00274" name="l00274"></a> 274 //This loop may or may not need to be done by a application. But is here

<a id="l00275" name="l00275"></a> 275 //to show potential cleanup when terminating early. If terminating you may

<a id="l00276" name="l00276"></a> 276 //want to finish the current in flight timestep. Since the server has been

<a id="l00277" name="l00277"></a> 277 //told it is terminating in the signal handler above it will not accept new

<a id="l00278" name="l00278"></a> 278 //timesteps but will allow pending timesteps to still complete.

<a id="l00279" name="l00279"></a> 279 

<a id="l00280" name="l00280"></a> 280 //Note: A user probably will want to do more due dilligence than this when

<a id="l00281" name="l00281"></a> 281 //shutting down. A timestep that is waiting on a client that is hung or crashed

<a id="l00282" name="l00282"></a> 282 //will never flip from pending-&gt;complete currently. This could cause this loop

<a id="l00283" name="l00283"></a> 283 //to be infinite waiting on a client who will never send its data.

<a id="l00284" name="l00284"></a> 284 [dvs\_ret](dynamic__visualization__store__error__codes_8h.xhtml#a1d7466ae72e89fe36cbf2408b4f7d9c1) error = s_server-&gt;[update](class_d_v_s_1_1_i_server.xhtml#add6fcb530763dc217f5b3c17b25093c0)();

<a id="l00285" name="l00285"></a> 285 if (error != [DVS\_NONE](dynamic__visualization__store__error__codes_8h.xhtml#a83b88ce16159d34fe5ce63e7024462a7)) {

<a id="l00286" name="l00286"></a> 286 break;

<a id="l00287" name="l00287"></a> 287 }

<a id="l00288" name="l00288"></a> 288 //If the update() call above isn't called in this loop num\_pending will

<a id="l00289" name="l00289"></a> 289 //never change also calling this loop to be infinite. We must update the server

<a id="l00290" name="l00290"></a> 290 //to get timestep state changes.

<a id="l00291" name="l00291"></a> 291 error = s_server-&gt;[get\_timestep\_count](class_d_v_s_1_1_i_server.xhtml#a8a5339f222bcd46b06c2fa9a474b2c37)(num_pending, num_complete);

<a id="l00292" name="l00292"></a> 292 if (error != [DVS\_NONE](dynamic__visualization__store__error__codes_8h.xhtml#a83b88ce16159d34fe5ce63e7024462a7)) {

<a id="l00293" name="l00293"></a> 293 break;

<a id="l00294" name="l00294"></a> 294 }

<a id="l00295" name="l00295"></a> 295 // Avoid burning up a CPU waiting for the I/O to complete

<a id="l00296" name="l00296"></a> 296 std::this_thread::sleep_for(std::chrono::milliseconds(delay_ms));

<a id="l00297" name="l00297"></a> 297 }

<a id="l00298" name="l00298"></a> 298 

<a id="l00299" name="l00299"></a> 299 //Destroy the server on exit, guarding against the s\_server destruction here

<a id="l00300" name="l00300"></a> 300 //in case the signal handler above is triggered.

<a id="l00301" name="l00301"></a> 301 std::lock_guard&lt;std::mutex&gt; lock(s_server_mutex);

<a id="l00302" name="l00302"></a> 302 DVS::DESTROY_SERVER_INSTANCE(s_server);

<a id="l00303" name="l00303"></a> 303 s_server = nullptr;

<a id="l00304" name="l00304"></a> 304 

<a id="l00305" name="l00305"></a> 305 return 0;

<a id="l00306" name="l00306"></a> 306}

[DVS::IServer](class_d_v_s_1_1_i_server.xhtml)

Interface class used to run a dynamic data server in a thread accepting incoming client connections.

**Definition:** [dvs\_server\_interface.h:60](dvs__server__interface_8h_source.xhtml#l00059)



[DVS::IServer::get\_uri](class_d_v_s_1_1_i_server.xhtml#a087c3fed77651e0f62d7189f44a32443)

virtual const char * get_uri()=0

Get URI of this server.



[DVS::IServer::set\_option](class_d_v_s_1_1_i_server.xhtml#a1edb4dec67086f10bc0329b6adf9084c)

virtual void set_option(const char *key, const char *value)=0

Set a specific option on the server, these are used during startup See See Server Options.



[DVS::IServer::terminating](class_d_v_s_1_1_i_server.xhtml#a6cb1f69ad4b9213dde48d4cd5b3f2111)

virtual dvs_ret terminating()=0

Call to begin terminating the server.



[DVS::IServer::get\_timestep\_count](class_d_v_s_1_1_i_server.xhtml#a8a5339f222bcd46b06c2fa9a474b2c37)

virtual dvs_ret get_timestep_count(uint32_t &amp;num_pending, uint32_t &amp;num_complete) const =0

return the current number of pending and complete timesteps in the server



[DVS::IServer::startup\_unthreaded](class_d_v_s_1_1_i_server.xhtml#ac61ce2698eec1adb521bbbf60cb78756)

virtual dvs_ret startup_unthreaded(uint32_t server_number, uint32_t local_ranks)=0

Startup a server manually without threads.



[DVS::IServer::update](class_d_v_s_1_1_i_server.xhtml#add6fcb530763dc217f5b3c17b25093c0)

virtual dvs_ret update()=0

Perform a server update.



[dvs\_server\_interface.h](dvs__server__interface_8h.xhtml)

C++ Server API for using Dynamic Visualization Store Server.



[dynamic\_visualization\_store\_enums.h](dynamic__visualization__store__enums_8h.xhtml)

Contains enums used in C/C++ API.



[dvs\_ret](dynamic__visualization__store__error__codes_8h.xhtml#a1d7466ae72e89fe36cbf2408b4f7d9c1)

int32_t dvs_ret

Return value of methods, TODO.

**Definition:** [dynamic\_visualization\_store\_error\_codes.h:32](dynamic__visualization__store__error__codes_8h_source.xhtml#l00032)



[DVS\_NONE](dynamic__visualization__store__error__codes_8h.xhtml#a83b88ce16159d34fe5ce63e7024462a7)

\#define DVS_NONE

No detected error has occurred.

**Definition:** [dynamic\_visualization\_store\_error\_codes.h:103](dynamic__visualization__store__error__codes_8h_source.xhtml#l00103)



[main](test__dvs__server_8cpp.xhtml#a3c04138a5bfe5d72780bb7e82a18e627)

int main(int argc, char **argv)

Main method of test client application.

**Definition:** [test\_dvs\_server.cpp:73](test__dvs__server_8cpp_source.xhtml#l00073)



[signal\_callback\_handler](test__dvs__server_8cpp.xhtml#a89a8322bea357674e81ba9cbdefe0378)

void signal_callback_handler(int signum)

Simple signal handler to handle signal.

**Definition:** [test\_dvs\_server.cpp:55](test__dvs__server_8cpp_source.xhtml#l00055)