<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.bci2000.org/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Programming_Reference%3ASignalSharingClientLibDemo</id>
	<title>Programming Reference:SignalSharingClientLibDemo - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.bci2000.org/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Programming_Reference%3ASignalSharingClientLibDemo"/>
	<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:SignalSharingClientLibDemo&amp;action=history"/>
	<updated>2026-06-24T16:21:19Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:SignalSharingClientLibDemo&amp;diff=12366&amp;oldid=prev</id>
		<title>Mellinger: /* Client application code */</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:SignalSharingClientLibDemo&amp;diff=12366&amp;oldid=prev"/>
		<updated>2026-03-12T16:12:02Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Client application code&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:12, 12 March 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l17&quot;&gt;Line 17:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 17:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The simple example consists of a single source file.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The simple example consists of a single source file.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Note how the callback functions call the appropriate &amp;lt;tt&amp;gt;SSC_Lock*()&amp;lt;/tt&amp;gt; function, followed with processing of the data, and calling &amp;lt;tt&amp;gt;SSC_Release*()&amp;lt;/tt&amp;gt; as soon as possible. Also note that care is taken to call &amp;lt;tt&amp;gt;SSC_Release*()&amp;lt;/tt&amp;gt; only if the call to &amp;lt;tt&amp;gt;SSC_Lock*()&amp;lt;/tt&amp;gt; was successful.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Similarly, note how &amp;lt;tt&amp;gt;main()&amp;lt;/tt&amp;gt; calls &amp;lt;tt&amp;gt;SSC_DeleteConnector()&amp;lt;/tt&amp;gt; no matter whether an exception occurred or not.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;To avoid clutter, and throw an exception when an unexpected error has occurred, we define a &amp;lt;tt&amp;gt;SSC_SucceedOrThrow&amp;lt;/tt&amp;gt; class that can be used in place of a plain numeric variable to hold a function&#039;s return value.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Note how exceptions are caught in the &amp;lt;tt&amp;gt;main()&amp;lt;/tt&amp;gt; function before calling the &amp;lt;tt&amp;gt;SSC_DeleteConnector()&amp;lt;/tt&amp;gt; function. This is possible because &amp;lt;tt&amp;gt;SSC_CreateConnector()&amp;lt;/tt&amp;gt; guarantees to null the resulting handle if any error occurs. This implies that we can call &amp;lt;tt&amp;gt;SSC_DeleteConnector()&amp;lt;/tt&amp;gt; without using a dangling or otherwise invalid pointer.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l141&quot;&gt;Line 141:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 148:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Parameters==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Parameters==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wikidb-bci_:diff:1.41:old-12365:rev-12366:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:SignalSharingClientLibDemo&amp;diff=12365&amp;oldid=prev</id>
		<title>Mellinger: Created page with &quot;==Location== &lt;tt&gt;src/core/SignalProcessing/SignalSharingDemo/CppLibraryClient&lt;/tt&gt;  ==Synopsis== The &#039;&#039;SignalSharingClientLibDemo&#039;&#039; client demonstrates how to receive signal data from BCI2000, using the SignalSharingClient Library. SignalSharing allows to tap into BCI2000 processing by receiving any filter output signal through a combination of a TCP connection, and shared memory.  ==Function== The &#039;&#039;SignalSharing&#039;&#039; com...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:SignalSharingClientLibDemo&amp;diff=12365&amp;oldid=prev"/>
		<updated>2026-03-12T16:00:19Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Location== &amp;lt;tt&amp;gt;src/core/SignalProcessing/SignalSharingDemo/CppLibraryClient&amp;lt;/tt&amp;gt;  ==Synopsis== The &amp;#039;&amp;#039;SignalSharingClientLibDemo&amp;#039;&amp;#039; client demonstrates how to receive signal data from BCI2000, using the &lt;a href=&quot;/mediawiki/index.php/Technical_Reference:SignalSharingClient_Library&quot; title=&quot;Technical Reference:SignalSharingClient Library&quot;&gt;SignalSharingClient Library&lt;/a&gt;. SignalSharing allows to tap into BCI2000 processing by receiving any filter output signal through a combination of a TCP connection, and shared memory.  ==Function== The &amp;#039;&amp;#039;SignalSharing&amp;#039;&amp;#039; com...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Location==&lt;br /&gt;
&amp;lt;tt&amp;gt;src/core/SignalProcessing/SignalSharingDemo/CppLibraryClient&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Synopsis==&lt;br /&gt;
The &amp;#039;&amp;#039;SignalSharingClientLibDemo&amp;#039;&amp;#039; client demonstrates how to receive signal data from BCI2000, using the [[Technical Reference:SignalSharingClient Library|SignalSharingClient Library]].&lt;br /&gt;
SignalSharing allows to tap into BCI2000 processing by receiving any filter output signal through a combination of a TCP connection, and shared memory.&lt;br /&gt;
&lt;br /&gt;
==Function==&lt;br /&gt;
The &amp;#039;&amp;#039;SignalSharing&amp;#039;&amp;#039; component in BCI2000 shares its input signal through a &amp;lt;tt&amp;gt;GenericSignal&amp;lt;/tt&amp;gt; object which has been linked to a shared memory block using &amp;lt;tt&amp;gt;GenericSignal::ShareAcrossModules()&amp;lt;/tt&amp;gt;. A dedicated thread waits for signal updates, and sends signal data out to a separate application waiting on a TCP/IP connection.&lt;br /&gt;
&lt;br /&gt;
When the client application is running on a separate machine, full signal data are sent over the network. When the client is running on the same machine, only a reference to a shared memory block is sent. On the application side, unserializing the signal will transparently bind it to the shared memory block if available.&lt;br /&gt;
&lt;br /&gt;
The simple client application receives BCI2000 parameters and data blocks, and writes them into a parameter file, and a signal file.&lt;br /&gt;
&lt;br /&gt;
==Client application code==&lt;br /&gt;
The client application uses the [[Technical Reference:SignalSharingClient Library|SignalSharingClient Library]] to receive data from BCI2000. This way, it does not have to deal with BCI2000 messages but will see the raw data directly. The [[Technical Reference:SignalSharingClient Library|SignalSharingClient Library]] is contained in the file &amp;lt;tt&amp;gt;prog/SignalSharingClientLib.dll&amp;lt;/tt&amp;gt; for Windows, and carrying the appropriate file extension for shared libraries on other platforms. For convenience, header file and &amp;lt;tt&amp;gt;.lib&amp;lt;/tt&amp;gt; file (if any) are also located at &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The simple example consists of a single source file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;SignalSharingClientLib.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;fstream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;mutex&amp;gt;&lt;br /&gt;
&lt;br /&gt;
static std::string SSC_ResultToString(SSC_RESULT result)&lt;br /&gt;
{&lt;br /&gt;
    switch (result) {&lt;br /&gt;
    case SSC_SUCCESS:&lt;br /&gt;
        return &amp;quot;Success&amp;quot;;&lt;br /&gt;
    case SSC_INVALID_ARG:&lt;br /&gt;
        return &amp;quot;Invalid argument&amp;quot;;&lt;br /&gt;
    case SSC_CANNOT_LISTEN:&lt;br /&gt;
        return &amp;quot;Cannot listen on given address&amp;quot;;&lt;br /&gt;
    case SSC_CANNOT_FULFILL_REQUEST:&lt;br /&gt;
        return &amp;quot;Cannot fulfill request at this time&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    return &amp;quot;Unknown error&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Translate an error code into an exception&lt;br /&gt;
struct SSC_SucceedOrThrow&lt;br /&gt;
{&lt;br /&gt;
    SSC_SucceedOrThrow(SSC_RESULT result)&lt;br /&gt;
    {&lt;br /&gt;
        if (result != SSC_SUCCESS) {&lt;br /&gt;
            throw std::runtime_error(SSC_ResultToString(result));&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
// The data we need inside the callback functions&lt;br /&gt;
struct ConnectorData&lt;br /&gt;
{&lt;br /&gt;
    SSC_HANDLE h = nullptr;&lt;br /&gt;
    std::ofstream paramfile, datafile;&lt;br /&gt;
    std::mutex mutex;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
// Callback function for handling parameters&lt;br /&gt;
static void HandleParameters(void* pData)&lt;br /&gt;
{&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Received parameters ...&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    auto pConnectorData = static_cast&amp;lt;ConnectorData*&amp;gt;(pData);&lt;br /&gt;
    const char* const* parameterLines = nullptr;&lt;br /&gt;
    int count = 0;&lt;br /&gt;
    if (SSC_SUCCESS == ::SSC_LockParameters(pConnectorData-&amp;gt;h, &amp;amp;parameterLines, &amp;amp;count)) {&lt;br /&gt;
        std::unique_lock lock(pConnectorData-&amp;gt;mutex);&lt;br /&gt;
        for (int i = 0; i &amp;lt; count; ++i) {&lt;br /&gt;
            pConnectorData-&amp;gt;paramfile &amp;lt;&amp;lt; parameterLines[i] &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
        lock.unlock();&lt;br /&gt;
        ::SSC_ReleaseParameters(pConnectorData-&amp;gt;h);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Callback function for handling signals&lt;br /&gt;
static void HandleSignal(void* pData)&lt;br /&gt;
{&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Received signal ...&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    auto pConnectorData = static_cast&amp;lt;ConnectorData*&amp;gt;(pData);&lt;br /&gt;
    union { const double* d; const char* c; } pSignal = { nullptr };&lt;br /&gt;
    int channels = 0, samples = 0;&lt;br /&gt;
    if (SSC_SUCCESS == ::SSC_LockSignal(pConnectorData-&amp;gt;h, &amp;amp;pSignal.d, &amp;amp;channels, &amp;amp;samples, nullptr)) {&lt;br /&gt;
        std::unique_lock lock(pConnectorData-&amp;gt;mutex);&lt;br /&gt;
        // Transpose data so we have a continuous stream of samples across channels&lt;br /&gt;
        for (int sample = 0; sample &amp;lt; samples; ++sample) {&lt;br /&gt;
            for (int ch = 0; ch &amp;lt; channels; ++ch) {&lt;br /&gt;
                // Data comes in channel-major format&lt;br /&gt;
                int idx = ch * samples + sample;&lt;br /&gt;
                pConnectorData-&amp;gt;datafile.write(pSignal.c + idx * sizeof(double), sizeof(double));&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        lock.unlock();&lt;br /&gt;
        ::SSC_ReleaseSignal(pConnectorData-&amp;gt;h);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
    std::string address = &amp;quot;localhost:1879&amp;quot;;&lt;br /&gt;
    if (argc &amp;gt; 1)&lt;br /&gt;
        address = argv[1];&lt;br /&gt;
&lt;br /&gt;
    std::string paramfile = &amp;quot;sscparams.prm&amp;quot;;&lt;br /&gt;
    if (argc &amp;gt; 2)&lt;br /&gt;
        paramfile = argv[2];&lt;br /&gt;
&lt;br /&gt;
    std::string datafile = &amp;quot;sscdata.raw&amp;quot;;&lt;br /&gt;
    if (argc &amp;gt; 3)&lt;br /&gt;
        datafile = argv[3];&lt;br /&gt;
&lt;br /&gt;
    // The main function&amp;#039;s return value&lt;br /&gt;
    int result = 0;&lt;br /&gt;
&lt;br /&gt;
    ConnectorData data;&lt;br /&gt;
    // Callback functions are called from a separate thread, so let&amp;#039;s lock the mutex&lt;br /&gt;
    // (not really necessary here because the thread will first start inside SSC_CreateConnector() below)&lt;br /&gt;
    std::unique_lock lock(data.mutex);&lt;br /&gt;
    data.paramfile.open(paramfile);&lt;br /&gt;
    data.datafile.open(datafile, std::ios::binary | std::ios::out);&lt;br /&gt;
    lock.unlock();&lt;br /&gt;
    try {&lt;br /&gt;
        SSC_SucceedOrThrow result = ::SSC_CreateConnector(address.c_str(), &amp;amp;data.h);&lt;br /&gt;
        result = ::SSC_RegisterParametersCallback(data.h, &amp;amp;HandleParameters, &amp;amp;data);&lt;br /&gt;
        result = ::SSC_RegisterSignalCallback(data.h, &amp;amp;HandleSignal, &amp;amp;data);&lt;br /&gt;
&lt;br /&gt;
        // Callback functions are called from a separate thread, so just wait for user input&lt;br /&gt;
        std::cout &amp;lt;&amp;lt; &amp;quot;Press &amp;lt;Enter&amp;gt; to quit&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
        std::string ignored;&lt;br /&gt;
        std::getline(std::cin, ignored);&lt;br /&gt;
    }&lt;br /&gt;
    catch (const std::exception&amp;amp; exc) {&lt;br /&gt;
        std::cerr &amp;lt;&amp;lt; &amp;quot;Error: &amp;quot; &amp;lt;&amp;lt; exc.what() &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
        result = -1;&lt;br /&gt;
    }&lt;br /&gt;
    ::SSC_DeleteConnector(data.h);&lt;br /&gt;
    return result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
===ShareTransmissionFilter===&lt;br /&gt;
IP address and port number of the client application. The client&amp;#039;s default address is &amp;lt;tt&amp;gt;localhost:1879&amp;lt;/tt&amp;gt; but may be changed on the client&amp;#039;s command line.&lt;br /&gt;
&lt;br /&gt;
The example uses the &amp;#039;&amp;#039;ShareTransmissionFilter&amp;#039;&amp;#039; parameter but any other filter&amp;#039;s &amp;#039;&amp;#039;Share&amp;lt;FilterName&amp;gt;&amp;#039;&amp;#039; parameter under the &amp;#039;&amp;#039;SignalSharing&amp;#039;&amp;#039; tab will work as well to visualize the chosen filter&amp;#039;s output signal.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:SignalSharing]], [[Programming Reference:GenericSignal Class]],  [[Programming Reference:SignalSharing Python Demo]], [[Programming Reference:SignalSharingClientLibDemo]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Framework API]][[Category:Howto]][[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
</feed>