<div dir="ltr"><div><div>Hi Travis,<br><br></div>I think you mean the MobileRemoteControl plugin, right?  Can you paste more of your code?  From what you have shared, it&#39;s hard to know where things are going wrong.  My guess is that you are forgetting to receive the &quot;ready&quot; command: after connecting to the socket, you should first receive 4 bytes and convert them to an int.  The int should have the value 1.  That&#39;s the &quot;ready&quot; command.  Next comes the code you showed in your email: send the &quot;send metadata command&quot; which is an int with value 2 and should be 4 bytes.  In the code you pasted, you are using sizeof(command) but don&#39;t show where you declare command, so that might also be a problem, if your data type is not 4 bytes.<br>


<br></div><div>Here is a python example that connects to paraview and receives the metadata:<br><br><br>import socket<br>from struct import pack<br>from struct import unpack<br><br><br>def connect(host, port):<br>    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br>


    s.connect((host, port))<br>    return s<br><br><br>def receiveReadyCommand(s):<br>    data = s.recv(4)<br>    assert unpack(&#39;i&#39;, data)[0] == 1<br><br><br>def sendCommand(s, command):<br>    data = pack(&#39;i&#39;, command)<br>


    s.send(data)<br><br><br>def receiveMetaData(s):<br>    sendCommand(s, 2)<br>    data = s.recv(8)<br>    length = unpack(&#39;Q&#39;, data)[0]<br>    return s.recv(length)<br><br><br>def main():<br><br>    s = connect(&#39;localhost&#39;, 40000)<br>


    receiveReadyCommand(s)<br><br>    print receiveMetaData(s)<br><br><br>if __name__ == &#39;__main__&#39;:<br>    main()<br><br><br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Apr 20, 2013 at 6:23 AM, Bueter, Travis J. (S&amp;T-Student) <span dir="ltr">&lt;<a href="mailto:tjbxv7@mail.mst.edu" target="_blank">tjbxv7@mail.mst.edu</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div link="blue" vlink="purple" lang="EN-US">
<div>
<p class="MsoNormal">Hi,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I am trying to get the “metadata” from ParaView by connecting to the socket. I’m having an issue where I am correctly sending the command to send the data but I’m not receiving the length value or string correctly. Below is my method how
 I am currently trying to get the length value:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">// In the main program //<u></u><u></u></p>
<p class="MsoNormal">                command = 2;<u></u><u></u></p>
<p class="MsoNormal">                if(-1 == send(socket, &amp;command, sizeof(command), 0))<u></u><u></u></p>
<p class="MsoNormal">                                exit(1);<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">                int size;<u></u><u></u></p>
<p class="MsoNormal">                unsigned long long length;<u></u><u></u></p>
<p class="MsoNormal">                if((size = Receive(socket, &amp;length, sizeof(unsigned long long)) &lt;= 0)<u></u><u></u></p>
<p class="MsoNormal">                                exit(1);<u></u><u></u></p>
<p class="MsoNormal">                cout &lt;&lt; size &lt;&lt; endl;<u></u><u></u></p>
<p class="MsoNormal">                cout &lt;&lt; length &lt;&lt; endl;<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">// Receive function //<u></u><u></u></p>
<p class="MsoNormal" style="text-indent:.5in">int Receive( cons int sk, void* data, int len)<u></u><u></u></p>
<p class="MsoNormal" style="text-indent:.5in">{<u></u><u></u></p>
<p class="MsoNormal">                                char* buffer = reinterpret_cast&lt;char*&gt;(data);<u></u><u></u></p>
<p class="MsoNormal">                                int total = 0;<u></u><u></u></p>
<p class="MsoNormal">                                do<u></u><u></u></p>
<p class="MsoNormal">                                {<u></u><u></u></p>
<p class="MsoNormal">                                                int nRecvd = recv(socket, buffered+total, len-total, 0);<u></u><u></u></p>
<p class="MsoNormal">                                                if(nRecvd == 0)<u></u><u></u></p>
<p class="MsoNormal">                                                {<u></u><u></u></p>
<p class="MsoNormal">                                                                cout &lt;&lt; “No Data Received” &lt;&lt; endl;<u></u><u></u></p>
<p class="MsoNormal">                                                                exit(1);<u></u><u></u></p>
<p class="MsoNormal">                                                }<u></u><u></u></p>
<p class="MsoNormal">                                                if(nRecvd == -1)<u></u><u></u></p>
<p class="MsoNormal">                                                {<u></u><u></u></p>
<p class="MsoNormal">                                                                cout &lt;&lt; “Error” &lt;&lt; endl;<u></u><u></u></p>
<p class="MsoNormal">                                                                exit(1);<u></u><u></u></p>
<p class="MsoNormal">                                                }<u></u><u></u></p>
<p class="MsoNormal">                                                total += nRecvd;<u></u><u></u></p>
<p class="MsoNormal">                                }while(total &lt; len);<u></u><u></u></p>
<p class="MsoNormal">                                return total;<u></u><u></u></p>
<p class="MsoNormal">                }<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Now in the source code of the MobileSocketPlugin, I added a printf to show the value of “length” before it is sent over the socket.  When I run my code, it succeeds without an error but the value of my “length” is not equal.  For example,
 if I connect and run my code immediately after starting up ParaView, it always sends a value of “1733”  but I receive a value of “7443178323969” every time.  I’m really not sure what I need to change to get this correct.  If someone could point me in the right
 direction on what I need to be doing to receive the metadata through MobileSocketPlugin, I would greatly appreciate it!
<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><b><span style="font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">Travis J. Bueter<u></u><u></u></span></b></p>
<p class="MsoNormal"><span style="font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">----------------------------------------------------------------------<u></u><u></u></span></p>
<p class="MsoNormal"><i><span style="font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">Missouri University of Science and Technology - Junior<b><u></u><u></u></b></span></i></p>
<p class="MsoNormal"><span style="font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">B.S. Computer Engineering/Computer Science<u></u><u></u></span></p>
<p class="MsoNormal"><a href="mailto:tjbxv7@mail.mst.edu" target="_blank"><span style="font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;color:blue">tjbxv7@mail.mst.edu</span></a><span style="font-family:&quot;Times New Roman&quot;,&quot;serif&quot;"><u></u><u></u></span></p>



<p class="MsoNormal"><span style="font-family:&quot;Times New Roman&quot;,&quot;serif&quot;"><a href="tel:%28573%29-238-5843" value="+15732385843" target="_blank">(573)-238-5843</a><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Times New Roman&quot;,&quot;serif&quot;"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">IT RSS<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">Treasurer – MS&amp;T Robotics Competition Team<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">----------------------------------------------------------------------<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>

<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
<br></blockquote></div><br></div></div>