<html><head><base href="x-msg://50/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Dear Amelie<div><br></div><div><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div lang="FR" link="blue" vlink="purple"><div class="Section1" style="page: Section1; "><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 12pt; font-family: 'Times New Roman'; "><font size="2" face="Arial"><span lang="EN-GB" style="font-size: 10pt; font-family: Arial; ">I’m implementing a realtime buffer in C++ pretty much like in “demo_combined” : my application creates a buffer server and an acquisition client.<o:p></o:p></span></font></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 12pt; font-family: 'Times New Roman'; "><font size="2" face="Arial"><span lang="EN-GB" style="font-size: 10pt; font-family: Arial; ">I encountered a first problem when trying to close the buffer server cleanly, but with some small changes in tcpsocket.c and tcpserver.c, I think I solved the problem.<o:p></o:p></span></font></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 12pt; font-family: 'Times New Roman'; "><font size="2" face="Arial"><span lang="EN-GB" style="font-size: 10pt; font-family: Arial; ">If these modifications can be useful for other users and do not create other problems, I will share them.<o:p></o:p></span></font></div></div></div></span></blockquote></div><div><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div lang="FR" link="blue" vlink="purple"><div class="Section1" style="page: Section1; "><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 12pt; font-family: 'Times New Roman'; "><font size="2" face="Arial"><span lang="EN-GB" style="font-size: 10pt; font-family: Arial; "><br></span></font></div></div></div></span></div><div>If you have changes that don't break the ANSI-C compilation then I am certainly happy to include them in our version. Please go to <a href="http://bugzilla.fcdonders.nl">http://bugzilla.fcdonders.nl</a> and submit a bug/request in which you attach the updated files.</div><div><br></div><div><div><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div lang="FR" link="blue" vlink="purple"><div class="Section1" style="page: Section1; "><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 12pt; font-family: 'Times New Roman'; "><font size="2" face="Arial"><span lang="EN-GB" style="font-size: 10pt; font-family: Arial; ">I encounter now a new problem : what if there are several acquisition clients ?<o:p></o:p></span></font></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 12pt; font-family: 'Times New Roman'; "><font size="2" face="Arial"><span lang="EN-GB" style="font-size: 10pt; font-family: Arial; ">I tried to create several couples “buffer-server + acquisition client” in different threads in my application, but it does not work at all, because of global variables (I suppose).</span></font></div></div></div></span></blockquote><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div lang="FR" link="blue" vlink="purple"><div class="Section1" style="page: Section1; "><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 12pt; font-family: 'Times New Roman'; "><font size="2" face="Arial"><span lang="EN-GB" style="font-size: 10pt; font-family: Arial; ">It seems that one buffer server can not manage several acquisition clients, but I’m not sure of this point.<o:p></o:p></span></font></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 12pt; font-family: 'Times New Roman'; "><font size="2" face="Arial"><span lang="EN-GB" style="font-size: 10pt; font-family: Arial; ">Did anyone encounter this problem (or solve it) ?<o:p></o:p></span></font></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 12pt; font-family: 'Times New Roman'; "><font size="2" face="Arial"><span lang="EN-GB" style="font-size: 10pt; font-family: Arial; ">Or do anyone have an idea ?</span></font></div></div></div></span></blockquote><div><br></div></div>You are right about the global variables. The buffer is implemented using multithreading and to ensure that incoming data (Write) does not interfere with outgoing (read) data a mutex (<a href="http://en.wikipedia.org/wiki/Mutual_exclusion">http://en.wikipedia.org/wiki/Mutual_exclusion</a>) is set. That mutex is shared throughout the code so that all pieces of code  are aware of when they are allowed to change the buffer content.</div><div><br></div><div>Having multiple buffers would require multiple mutexes and multiple (separately identifyable) memory segments for the actual data. That would require a lot of changes to the code.</div><div><br></div><div>You can run multiple buffers on the same computer, but you would have to start them separately and they would have to have different TCP ports. The application you are writing could write different aspects to the different TCP ports. You can use fieldtrip/realtime/general/buffer.exe, which in fact is a compiled version of fieldtrip/realtime/buffer/test/demo_buffer. Note that you would use it as</div><div><br></div><div><div><div><div>buffer.exe localhost 2340</div></div><div></div></div></div><div><div><div>buffer.exe localhost 2341</div></div><div></div></div><div><div><div>buffer.exe localhost 2342</div></div><div></div></div><div><div><div>buffer.exe localhost 2343</div></div><div><br></div><div>to start 4 buffers on ports 2340-2343. The "localhost" argument is not used, but still appears to be required according to the demo_buffer.c source code. Of course it is cumbersome to have to start the 4 seperate processes on top of your own application. On unix-like computers you should be able to write a single application that at the beginning forks into a parent and child, where the parent continues as your application and where the child (which is then a separate process) can start the buffer. You can fork multiple times, to have multiple buffers (one per child).  </div><div><br></div><div>best</div><div>Robert</div><div><br></div><div><br></div><div><br></div><div><br></div><div></div></div></body></html>