title: How to unpack c struct in python 3.2?
body: <p>I'm working on a server (implemented in Python) client (implemented in C) application.
  I want to unpack raw bytes received from a C client using struct module at server side (Python). </p>
  
  <p>My C structure (from C client):</p>
  
  <pre><code>typedef struct lokesh{
      int command;
  
       union 
       {
          struct{
              int data[100];
              int ttl[100];
          };
  
          struct{
              char config[256];
  
          };   
       };
  } mystructdata;
  </code></pre>
  
  <p>Unpacking at server side (Python):-</p>
  
  <pre><code>import struct
  
  data,address=socket.recvfrom(1024)
  result=struct.unpack('&lt;i 2048s',data)
  print(result[0])
  </code></pre>
  
  <p>But I'm getting an error :-</p>
  
  <pre><code>struct.error: unpack require object of size 2052  
  </code></pre>
  
  <p>I think problem is in my unpack method's format string <code>'&lt;i 2048s'</code> argument.</p>
  
  <p>Edit :- </p>
  
  <blockquote>
    <p>now, i have replaced format string <code>'&lt;i 2048s'</code> with format string
    <code>'&lt;i 256s'</code></p>
  </blockquote>