<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
<link rel="self" type="application/atom+xml" href="http://theeyetribe.com/forum/feed.php?f=25&amp;t=132" />

<title>The Eye Tribe</title>
<subtitle>Developer Forum</subtitle>
<link href="http://theeyetribe.com/forum/index.php" />
<updated>2015-03-03T11:06:14+02:00</updated>

<author><name><![CDATA[The Eye Tribe]]></name></author>
<id>http://theeyetribe.com/forum/feed.php?f=25&amp;t=132</id>
<entry>
<author><name><![CDATA[Cheveoner]]></name></author>
<updated>2015-03-03T11:06:14+02:00</updated>
<published>2015-03-03T11:06:14+02:00</published>
<id>http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1755#p1755</id>
<link href="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1755#p1755"/>
<title type="html"><![CDATA[Re: Quick and dirty client application for windows]]></title>

<content type="html" xml:base="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1755#p1755"><![CDATA[
Nevermind, it was this line in the RenderThread which was making the thread to exit without finishing what I wanted it to do<br />&quot;if(0&gt;=bytesReceived) return 0;&quot;<br /><br />Cheers!<p>Statistics: Posted by <a href="http://theeyetribe.com/forum/memberlist.php?mode=viewprofile&amp;u=7382">skataCheveoner</a> — 03 Mar 2015, 11:06</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Cheveoner]]></name></author>
<updated>2015-02-26T15:23:16+02:00</updated>
<published>2015-02-26T15:23:16+02:00</published>
<id>http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1748#p1748</id>
<link href="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1748#p1748"/>
<title type="html"><![CDATA[Re: Quick and dirty client application for windows]]></title>

<content type="html" xml:base="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1748#p1748"><![CDATA[
Thanks for this client, it works perfectly until I start making things with it heh <br /><br />My problem is that when I press enter, everything I want to do inside ReaderThread after the loop and before the return (save some fixation maps), is not executed. I tried changing the timeout of WaitForSingleObject to INFINTE (just in case the thread is not alllowed to finish properly), but I couldn't make it work. <br /><br />Any suggestions? <br /><br />Thanks in advance!<p>Statistics: Posted by <a href="http://theeyetribe.com/forum/memberlist.php?mode=viewprofile&amp;u=7382">skataCheveoner</a> — 26 Feb 2015, 15:23</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[MastaLomaster]]></name></author>
<updated>2015-02-09T13:34:12+02:00</updated>
<published>2015-02-09T13:34:12+02:00</published>
<id>http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1725#p1725</id>
<link href="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1725#p1725"/>
<title type="html"><![CDATA[Re: Quick and dirty client application for windows]]></title>

<content type="html" xml:base="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1725#p1725"><![CDATA[
<blockquote><div><cite>jean.lorenceau@upmc.fr wrote:</cite><br />why is it necessary to call the &quot;recv&quot; routine twice (one with fix=0 and then with fix=1 in case the first call did not succeded )..<br /></div></blockquote><br /><br />It is not &quot;recv&quot;, but &quot;sscanf&quot; function called twice.<br /><br />The incoming data may contain &quot;fix:true&quot; or &quot;fix:false&quot; substring.<br />I would like to obtain this &quot;true&quot; or &quot;false&quot; value using the regular &quot;sscanf&quot; function. But I didn't manage. Templates like &quot;fix:%s&quot; didn't work for me.<br /><br />So I prepared two templates  (char *JSON_frame_true, *JSON_frame_false)<br />The only difference between them is &quot;fix:true&quot; or &quot;fix:false&quot; somewhere in the middle.<br /><br />First I try to sscanf using JSON_frame_false. If it succeeds (returns 20 scanned values), then the <span style="font-style: italic">fix</span> variable remains 0;<br />If it doesn't -  the <span style="font-style: italic">fix</span> variable is changed to 1 and we try to sscanf once again with the template containing &quot;fix:true&quot;.<br /><br />If you know the way to scanf strings like &quot;fix:%s&quot; I would appreciate.<br />(P.S. remember, it was &quot;quick and dirty&quot; code).<p>Statistics: Posted by <a href="http://theeyetribe.com/forum/memberlist.php?mode=viewprofile&amp;u=2722">skataMastaLomaster</a> — 09 Feb 2015, 13:34</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Anders]]></name></author>
<updated>2014-12-13T15:57:00+02:00</updated>
<published>2014-12-13T15:57:00+02:00</published>
<id>http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1583#p1583</id>
<link href="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1583#p1583"/>
<title type="html"><![CDATA[Re: Quick and dirty client application for windows]]></title>

<content type="html" xml:base="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1583#p1583"><![CDATA[
Fixation is basically keeping your visual fixation in the same place for a certain amount of time. Read more <a href="http://en.wikipedia.org/wiki/Fixation_%28visual%29" class="postlink">here</a>. So the value of the API tells you if the gaze 'is fixated' at a certain area. This is usefull when dealing with selection and dwell time.<br /><br />BR,<br />Anders<p>Statistics: Posted by <a href="http://theeyetribe.com/forum/memberlist.php?mode=viewprofile&amp;u=120">skataAnders</a> — 13 Dec 2014, 15:57</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[jean.lorenceau@upmc.fr]]></name></author>
<updated>2014-11-27T15:42:54+02:00</updated>
<published>2014-11-27T15:42:54+02:00</published>
<id>http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1523#p1523</id>
<link href="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1523#p1523"/>
<title type="html"><![CDATA[Re: Quick and dirty client application for windows]]></title>

<content type="html" xml:base="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1523#p1523"><![CDATA[
Thanks a lot for this very simple code that avoids depending on the boost library and all other stuff.. I really appreciate having a direct hand on the EyeTribe with such a simple code.. I suggest that TheEyeTribe should advertise more these routines (perhaps providing a *.lib that includes these routines plus a calib routine) ... Would be great to extend the code so as to calibrate &quot;from the inside&quot;  without depending upon the UI framework ... <br />In addition, a question: why is it necessary to call the &quot;recv&quot; routine twice (one with fix=0 and then with fix=1 in case the first call did not succeded ).. Also, what is the meaning of the &quot;fix&quot; variable which is poorly documented (the only information I could find is fix :   // is fixated ?) ? <br /><br />Thanks again !!<br />Best <br /><br />Jean<p>Statistics: Posted by <a href="http://theeyetribe.com/forum/memberlist.php?mode=viewprofile&amp;u=2434">skatajean.lorenceau@upmc.fr</a> — 27 Nov 2014, 15:42</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[wxz]]></name></author>
<updated>2014-08-20T15:37:57+02:00</updated>
<published>2014-08-20T15:37:57+02:00</published>
<id>http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1312#p1312</id>
<link href="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1312#p1312"/>
<title type="html"><![CDATA[Re: Quick and dirty client application for windows]]></title>

<content type="html" xml:base="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1312#p1312"><![CDATA[
Developing calibration routine is more involved as it requires a UI framework (MFC, WPF, wxWidget etc.) to draw those dots on the screen one at a time.  <br /><br />For now, the easiest way is to use the calibration procedure provided by Eye Tribe.  Once calibration is done, you can close UI.  It's my impression that calibration is needed if Server restarts or the gaze data become deteriorated.<p>Statistics: Posted by <a href="http://theeyetribe.com/forum/memberlist.php?mode=viewprofile&amp;u=2499">skatawxz</a> — 20 Aug 2014, 15:37</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[SimonH]]></name></author>
<updated>2014-08-20T15:13:34+02:00</updated>
<published>2014-08-20T15:13:34+02:00</published>
<id>http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1311#p1311</id>
<link href="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1311#p1311"/>
<title type="html"><![CDATA[Re: Quick and dirty client application for windows]]></title>

<content type="html" xml:base="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1311#p1311"><![CDATA[
Great sample MastaLomasta and good advise wxz.<br /><br />This helped me alot!<br /><br />Did any of you figure out an easy way to integrate a calibration routine in c++ yet? I dont want to use the UI for it everytime, but i cant figure out a way on my own <img src="http://theeyetribe.com/forum/images/smilies/icon_e_sad.gif" alt=":(" title="Sad" /><br /><br />Thx in advance!<p>Statistics: Posted by <a href="http://theeyetribe.com/forum/memberlist.php?mode=viewprofile&amp;u=4700">skataSimonH</a> — 20 Aug 2014, 15:13</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[wxz]]></name></author>
<updated>2014-08-19T23:16:05+02:00</updated>
<published>2014-08-19T23:16:05+02:00</published>
<id>http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1305#p1305</id>
<link href="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1305#p1305"/>
<title type="html"><![CDATA[Re: Quick and dirty client application for windows]]></title>

<content type="html" xml:base="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1305#p1305"><![CDATA[
ok, tried out the code and it works.  <br />Just a reminder, in order to compile, do NOT include &quot;winsock.h&quot;,  &quot;windows.h&quot; already includes &quot;winsock2.h&quot;.  Include &quot;winsock.h&quot; after &quot;winsock2.h&quot; causes issues.<br /><br />Also, add the line:<br />#pragma comment (lib, &quot;ws2_32.lib&quot;)<br /><br />for linkage.<br /><br />About the heartbeat, it only requires once a second as done in the SDK.<p>Statistics: Posted by <a href="http://theeyetribe.com/forum/memberlist.php?mode=viewprofile&amp;u=2499">skatawxz</a> — 19 Aug 2014, 23:16</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[wxz]]></name></author>
<updated>2014-08-07T18:49:52+02:00</updated>
<published>2014-08-07T18:49:52+02:00</published>
<id>http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1236#p1236</id>
<link href="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1236#p1236"/>
<title type="html"><![CDATA[Re: Quick and dirty client application for windows]]></title>

<content type="html" xml:base="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=1236#p1236"><![CDATA[
I'm curious about the heartbeat thread.  It sends the message once every second. But in the API reference,  it says &quot;heartbeats must be sent at a rate matching the heartbeatinterval value of the tracker category.&quot;  In other words, if the data is 30 fps, the heartbeat should be sent every 1000/30 ms.<br /><br />I didn't try out the code, but I'm curious if it works, does that mean we can send the heartbeat at a lower rate?<p>Statistics: Posted by <a href="http://theeyetribe.com/forum/memberlist.php?mode=viewprofile&amp;u=2499">skatawxz</a> — 07 Aug 2014, 18:49</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Martin]]></name></author>
<updated>2014-03-10T23:23:10+02:00</updated>
<published>2014-03-10T23:23:10+02:00</published>
<id>http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=545#p545</id>
<link href="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=545#p545"/>
<title type="html"><![CDATA[Re: Quick and dirty client application for windows]]></title>

<content type="html" xml:base="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=545#p545"><![CDATA[
Thanks for posting. I'll forward your comments to the dev team to see if we can make it easier or a more lightweight SDK. Meanwhile, there has been some additional work on the current C++ SDK which will go on Github in the next couple of days. <br /><br />As for the Boost dependency, there are several alternatives, one could be <a href="http://www.alhem.net/Sockets/index.html" class="postlink">C++ Sockets Library</a>. It's rather important that it builds on several platforms, that's why we went with the Boost libraries.<p>Statistics: Posted by <a href="http://theeyetribe.com/forum/memberlist.php?mode=viewprofile&amp;u=117">skataMartin</a> — 10 Mar 2014, 23:23</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[MastaLomaster]]></name></author>
<updated>2014-03-09T01:45:37+02:00</updated>
<published>2014-03-09T01:45:37+02:00</published>
<id>http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=536#p536</id>
<link href="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=536#p536"/>
<title type="html"><![CDATA[Quick and dirty client application for windows]]></title>

<content type="html" xml:base="http://theeyetribe.com/forum/viewtopic.php?t=132&amp;p=536#p536"><![CDATA[
DON'T read this post if:<br />- you are happy with installing multi-Magabyte set of &quot;Boost&quot; libraries and injecting something from there into your application<br />- you are happy with handling exceptions thrown from some &quot;Boost&quot; element<br />- you like new language extentions, like BOOST_FOREACH<br />- you are happy with CMake and its fantastic syntax<br />- you like to link MSVCRTxx.DLL with the Boost libraries and 100% sure they use the same heap and threads handling <br />- the application you've made using SDK is extremely stable<br /><br />Otherwise please take a look at the small console application (190 lines of code) made in MS Visual Studio 10 SP1.<br />It connects to the local eyetracker and prints the screen coordinates until you press the 'Enter' button.<br /><br />It does not need any of the SDK headers/libraries. And this is plain C, not  really C++.<br /><br />Of course, it has some disadvantages. Not much error checking and a lot of assumptions.<br /><br />You may tell me:<br /><br />&quot;What if the recv() function return only a part of the frame? Or two frames together?&quot;<br />It can. Theoretically. But in practice, if you work with loopback interface, this will never happen. Besides, the frame is never larger than minimal TCP MTU.<br />So you only spent extra CPU cycles and programming work trying to serialize what is already serialized.<br /><br />&quot;You don't parse every single bracket&quot;<br />Sure. I don't need it. The scanf() function is enough to parse these JSON data. <br /><br />&quot;What if they slightly change the frame format / protocol in the future?&quot; <br />Ok, then this app will not work. But you'll now how it works and will easily fix it. <br /><br />Here is the code. It works.<br /><br />Your comments are welcome.<br /><br /><dl class="codebox"><dt>Code: </dt><dd><code>#include &lt;Windows.h&gt;<br />#include &lt;stdio.h&gt;<br />#include &lt;process.h&gt;<br />#include &lt;winsock.h&gt;<br /><br />// The only two messages that we send to the server<br />char *JSON_heart_beat=&quot;{\&quot;category\&quot;:\&quot;heartbeat\&quot;}&quot;;<br />char *JSON_set_push=&quot;{\&quot;category\&quot;:\&quot;tracker\&quot;,\&quot;request\&quot;:\&quot;set\&quot;,\&quot;values\&quot;:{\&quot;push\&quot;:true,\&quot;version\&quot;:1}}&quot;;<br />// Scanf template for the frame (containing &quot;fix:false&quot;)<br />char *JSON_frame_false=&quot;{\&quot;category\&quot;:\&quot;tracker\&quot;,\&quot;request\&quot;:\&quot;get\&quot;,\&quot;statuscode\&quot;:200,\&quot;values\&quot;:{\&quot;frame\&quot;:{&quot;\<br />             &quot;\&quot;avg\&quot;:{\&quot;x\&quot;:%f,\&quot;y\&quot;:%f},\&quot;fix\&quot;:false,\&quot;lefteye\&quot;:{\&quot;avg\&quot;:{\&quot;x\&quot;:%f,\&quot;y\&quot;&quot;\<br />             &quot;:%f},\&quot;pcenter\&quot;:{\&quot;x\&quot;:%f,\&quot;y\&quot;:%f},\&quot;psize\&quot;:%f,\&quot;raw\&quot;:{\&quot;x\&quot;:%f&quot;\<br />             &quot;,\&quot;y\&quot;:%f}},\&quot;raw\&quot;:{\&quot;x\&quot;:%f,\&quot;y\&quot;:%f},\&quot;righteye\&quot;:{\&quot;avg\&quot;:{\&quot;x\&quot;:%f&quot;\<br />             &quot;,\&quot;y\&quot;:%f},\&quot;pcenter\&quot;:{\&quot;x\&quot;:%f,\&quot;y\&quot;:%f},\&quot;psize\&quot;:%f,\&quot;raw\&quot;:{\&quot;x\&quot;:%f&quot;\<br />             &quot;,\&quot;y\&quot;:%f}},\&quot;state\&quot;:%d,\&quot;time\&quot;:%d}}}&quot;;<br />// Scanf template for the frame (containing &quot;fix:true&quot;)<br />char *JSON_frame_true=&quot;{\&quot;category\&quot;:\&quot;tracker\&quot;,\&quot;request\&quot;:\&quot;get\&quot;,\&quot;statuscode\&quot;:200,\&quot;values\&quot;:{\&quot;frame\&quot;:{&quot;\<br />             &quot;\&quot;avg\&quot;:{\&quot;x\&quot;:%f,\&quot;y\&quot;:%f},\&quot;fix\&quot;:true,\&quot;lefteye\&quot;:{\&quot;avg\&quot;:{\&quot;x\&quot;:%f,\&quot;y\&quot;&quot;\<br />             &quot;:%f},\&quot;pcenter\&quot;:{\&quot;x\&quot;:%f,\&quot;y\&quot;:%f},\&quot;psize\&quot;:%f,\&quot;raw\&quot;:{\&quot;x\&quot;:%f&quot;\<br />             &quot;,\&quot;y\&quot;:%f}},\&quot;raw\&quot;:{\&quot;x\&quot;:%f,\&quot;y\&quot;:%f},\&quot;righteye\&quot;:{\&quot;avg\&quot;:{\&quot;x\&quot;:%f&quot;\<br />             &quot;,\&quot;y\&quot;:%f},\&quot;pcenter\&quot;:{\&quot;x\&quot;:%f,\&quot;y\&quot;:%f},\&quot;psize\&quot;:%f,\&quot;raw\&quot;:{\&quot;x\&quot;:%f&quot;\<br />             &quot;,\&quot;y\&quot;:%f}},\&quot;state\&quot;:%d,\&quot;time\&quot;:%d}}}&quot;;<br /><br />SOCKET TETSocket;<br /><br />volatile bool flag_ShutDownThreads=false; // flag to inform the threads to terminate<br /><br />uintptr_t handler_HeartBeat=0, handler_Reader=0; // thread handlers<br /><br />//==================================================<br />// HeartBeat thread - sends a message once a second<br />//==================================================<br />unsigned __stdcall HeartBeatThread(void *p)<br />{<br />   while(!flag_ShutDownThreads)<br />   {<br />      if(SOCKET_ERROR==send(TETSocket,JSON_heart_beat,strlen(JSON_heart_beat),0)) return 0; // Connection closed<br />      Sleep(1000);<br />   }<br />   return 0;<br />}<br /><br />//=========================================================<br />// Reader thread - receiving messages from the server here<br />//=========================================================<br />unsigned __stdcall ReaderThread(void *p)<br />{<br />   // big enough buffers...<br />   char buffer&#91;4096&#93;;<br />   char true_false_buffer&#91;128&#93;;<br /><br />   int bytesReceived;<br />   int num_scanned=0;<br /><br />   float x_avg,y_avg,<br />      left_x_avg, left_y_avg, left_pcenter_x, left_pcenter_y, left_psize, left_x_raw, left_y_raw,<br />      x_raw, y_raw,<br />      right_x_avg, right_y_avg, right_pcenter_x, right_pcenter_y, right_psize, right_x_raw, right_y_raw;<br />   int state, tet_time, fix;<br /><br />   while(!flag_ShutDownThreads)<br />   {<br />      bytesReceived = recv(TETSocket, buffer, 4095, 0);<br />      if(0&gt;=bytesReceived) return 0; // Connection closed<br />      buffer&#91;bytesReceived&#93;=0; // Make a string zero-terminated<br />      <br />      <br />      // First try. Template string contains &quot;fix:false&quot;<br />      fix=0;<br />      num_scanned=sscanf(buffer,JSON_frame_false,<br />         &amp;x_avg,&amp;y_avg,<br />         &amp;left_x_avg, &amp;left_y_avg, &amp;left_pcenter_x, &amp;left_pcenter_y, &amp;left_psize, &amp;left_x_raw, &amp;left_y_raw,<br />         &amp;x_raw, &amp;y_raw, <br />         &amp;right_x_avg, &amp;right_y_avg, &amp;right_pcenter_x, &amp;right_pcenter_y, &amp;right_psize, &amp;right_x_raw, &amp;right_y_raw,<br />         &amp;state, &amp;tet_time<br />         );<br />      // Second try. Template string contains &quot;fix:true&quot;<br />      if(20!=num_scanned)<br />      {<br />         fix=1;<br />         num_scanned=sscanf(buffer,JSON_frame_true,<br />         &amp;x_avg,&amp;y_avg,<br />         &amp;left_x_avg, &amp;left_y_avg, &amp;left_pcenter_x, &amp;left_pcenter_y, &amp;left_psize, &amp;left_x_raw, &amp;left_y_raw,<br />         &amp;x_raw, &amp;y_raw, <br />         &amp;right_x_avg, &amp;right_y_avg, &amp;right_pcenter_x, &amp;right_pcenter_y, &amp;right_psize, &amp;right_x_raw, &amp;right_y_raw,<br />         &amp;state, &amp;tet_time<br />         );<br />      }<br /><br />      if(20==num_scanned)<br />      {<br />         // Do domething real here instead of just printing<br />         //if(7==state) <br />         printf(&quot;X:%f Y:%f fix:%d state:%d\n&quot;,x_avg,y_avg,fix,state);<br />      }<br />   }<br />   return 0;<br />}<br /><br />//=========================================================<br />// Init TCP connection (socket)<br />//=========================================================<br />int TETconnect()<br />{<br />   WORD sockVersion;<br />   WSADATA wsaData;<br />   int nret;<br />   char *err_string;<br />   <br />   SOCKADDR_IN TETserver;<br /><br />   // Initialize Winsock<br />   sockVersion=MAKEWORD(2, 2);         <br /><br />   nret=WSAStartup(sockVersion, &amp;wsaData);<br />   if(nret)<br />   {<br />      err_string=&quot;Failed to initialize Winsock\n&quot;;<br />      goto ws_error;<br />   }<br /><br />   // Create a socket<br />   TETSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);      <br />   if (INVALID_SOCKET == TETSocket)<br />   {<br />      err_string=&quot;Cannot create socket\n&quot;;<br />      goto ws_error;<br />   }<br /><br />   // Local server <br />   TETserver.sin_family = AF_INET;<br />   TETserver.sin_addr.S_un.S_un_b.s_b1=127; // 127.0.0.1<br />   TETserver.sin_addr.S_un.S_un_b.s_b2=0;<br />   TETserver.sin_addr.S_un.S_un_b.s_b3=0;<br />   TETserver.sin_addr.S_un.S_un_b.s_b4=1;<br />   TETserver.sin_port = htons(6555);<br /><br />   // Connect the local server<br />   nret = connect(TETSocket, (LPSOCKADDR)&amp;TETserver, sizeof(struct sockaddr));<br />   if (SOCKET_ERROR == nret)<br />   {<br />      err_string=&quot;Cannot connect to server\n&quot;;<br />      goto ws_error;<br />   }<br /><br />   // Connected!!!<br />   fprintf(stderr,&quot;Connected to server!\n&quot;);<br />   return 0;<br /><br />ws_error:<br />   // Print error and shut down winsock<br />   fprintf(stderr,&quot;%s. Press 'Enter' to close the program.\n&quot;, err_string);<br />   WSACleanup();<br />   return 1;<br />}<br /><br />int main()<br />{<br />   char buffer&#91;4096&#93;; <br /><br />   // 1. Initialize TCP connection<br />   if(TETconnect()) goto cleanup;<br /><br />   // 2. Set Push mode<br />   send(TETSocket,JSON_set_push,strlen(JSON_set_push),0);<br />   recv(TETSocket, buffer, 4095, 0); // ignore the reply<br /><br />   // 2. Start heartbeat thread<br />   handler_HeartBeat=_beginthreadex(NULL,0,HeartBeatThread,0,0,NULL);<br />   if(1&gt;handler_HeartBeat) goto cleanup; // this will never happen... but...<br />      <br />   // 3. Start Reader thread<br />   handler_Reader=_beginthreadex(NULL,0,ReaderThread,0,0,NULL);<br />   if(1&gt;handler_Reader) goto cleanup; // this will never happen... but...<br />   <br />cleanup:<br />   //press 'Enter' to end the program<br />   getc(stdin);<br />   <br />   // Shut down winsock<br />   WSACleanup();<br /><br />   // Wait for threads to terminate<br />   flag_ShutDownThreads=true; // inform the threads to terminate<br />   if(handler_HeartBeat) WaitForSingleObject((HANDLE)handler_HeartBeat,0);<br />   if(handler_Reader) WaitForSingleObject((HANDLE)handler_Reader,0);<br /><br />   return 0;<br />}<br /></code></dd></dl><p>Statistics: Posted by <a href="http://theeyetribe.com/forum/memberlist.php?mode=viewprofile&amp;u=2722">skataMastaLomaster</a> — 09 Mar 2014, 01:45</p><hr />
]]></content>
</entry>
</feed>