<br>First, s.recv(4) is not guaranteed to always return 4 bytes.  It could return 0, 1, 2, 3, or 4, wtih 4 being the most likely.  To deal with this, I tend to use <a href="http://stromberg.dnsalias.org/~dstromberg/bufsock.html">http://stromberg.dnsalias.org/~dstromberg/bufsock.html</a> - but I suspect that Twisted has a way of dealing with it too.<br>
<br>Then, to put your data into a list, just create an empty list with [] and use list_.append(integer).<br><br>Or was there more to your question, like perhaps a traceback you haven't shared with us?<br><br><div class="gmail_quote">
On Fri, Aug 5, 2011 at 6:05 AM, Johnny Venter <span dir="ltr"><<a href="mailto:Johnny.Venter@zoho.com">Johnny.Venter@zoho.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div style="word-wrap: break-word;"><div><div style="margin: 0px;">I was not sure if this message was sent before my membership was accepted.</div><div style="margin: 0px; min-height: 17px;"><br></div><div style="margin: 0px;">
Please disregard if it's a duplicate.</div><div style="margin: 0px; min-height: 17px;"><br></div><div style="margin: 0px;">Thanks</div><div><br><div>Begin forwarded message:</div><br><blockquote type="cite"><div style="margin: 0px;">
<span style="font-family: 'Helvetica'; font-size: medium;"><b>From: </b></span><span style="font-family: 'Helvetica'; font-size: medium;">Johnny Venter <<a href="mailto:Johnny.Venter@zoho.com" target="_blank">Johnny.Venter@zoho.com</a>><br>
</span></div><div style="margin: 0px;"><span style="font-family: 'Helvetica'; font-size: medium;"><b>Date: </b></span><span style="font-family: 'Helvetica'; font-size: medium;">August 5, 2011 8:15:53 AM EDT<br>
</span></div><div style="margin: 0px;"><span style="font-family: 'Helvetica'; font-size: medium;"><b>To: </b></span><span style="font-family: 'Helvetica'; font-size: medium;"><a href="mailto:python-list@python.org" target="_blank">python-list@python.org</a><br>
</span></div><div style="margin: 0px;"><span style="font-family: 'Helvetica'; font-size: medium;"><b>Subject: </b></span><span style="font-family: 'Helvetica'; font-size: medium;"><b>Sockets: Receiving C Struct</b><br>
</span></div><br><div style="word-wrap: break-word;">New to python and would like to test network/sockets with it.<div><br></div><div>I am having a problem where I have setup the following:</div><div><br></div><div><div><font color="#0034ff">import socket, sys, struct</font></div>
<div><font color="#0034ff"><br></font></div><div><font color="#0034ff">HOST = '1.1.1.1'</font></div><div><font color="#0034ff">PORT = 153</font></div><div><font color="#0034ff">s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)</font></div>
<div><font color="#0034ff">s.connect((HOST, PORT))</font></div><div><font color="#0034ff"><br></font></div><div><font color="#0034ff">data = struct.unpack('!I',s.recv(4))[0]</font></div><div><font color="#0034ff"><br>
</font></div><div><font color="#0034ff">s.close()</font></div></div><div><font color="#0034ff"><br></font></div><div><font color="#0034ff">print data</font></div><div><font color="#0034ff"><br></font></div><div><font color="#0034ff"><br>
</font></div><div>What I would like to do is take the input from the server, and store it in an array.  The type of data is int.</div><div><br></div><div>Can someone help?</div><div><br></div><div><br></div><div>Thanks, Johnny</div>
<div><br></div></div></blockquote></div><br></div></div><br>--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
<br></blockquote></div><br>