Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.05; 'mrab': 0.05; 'chunk': 0.07; 'advice.': 0.09; "b''": 0.09; '"1.0",': 0.16; '"2":': 0.16; 'chunk:': 0.16; 'closed:': 0.16; 'received:124.108': 0.16; 'wrote:': 0.17; 'bytes': 0.17; 'feb': 0.19; 'thanks.': 0.21; 'connected': 0.24; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'url:mailman': 0.29; 'connection': 0.30; 'code': 0.31; 'url:python': 0.32; 'url:listinfo': 0.32; '11,': 0.33; 'to:addr:python-list': 0.33; 'received:172.16': 0.34; 'thanks': 0.34; 'url:org': 0.36; 'should': 0.36; 'charset:us- ascii': 0.36; 'sent:': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'url:mail': 0.40; 'your': 0.60; 'header:Message-Id:1': 0.62; 'received:': 0.62; '20,': 0.65; 'received:my': 0.93 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) Subject: Re: Python recv loop From: Ihsan Junaidi Ibrahim In-Reply-To: <51184F74.60902@mrabarnett.plus.com> Date: Mon, 11 Feb 2013 23:08:05 +0800 Content-Transfer-Encoding: quoted-printable References: <51184F74.60902@mrabarnett.plus.com> To: python-list@python.org X-Mailer: Apple Mail (2.1499) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360595288 news.xs4all.nl 6876 [2001:888:2000:d::a6]:39784 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38692 Hi MRAB, My code now works thanks to your advice. {"msgver": "1.0", "msgid": "200", "subcode": "100", "appver": "1.0", = "appid": "1.0", "data": {"1": "igb0", "2": "igb1", "ifcnt": "2"}} connected to misty:8080 sending data 138 bytes sent: 0x86{"msgver": "1.0", "msgid": "200", "subcode": "100", = "appver": "1.0", "appid": "1.0", "data": {"1": "igb0", "2": "igb1", = "ifcnt": "2"}} receiving data message length is 188 188 bytes received: { "msgver": 1.000000, "appver": 1.000000, "appid": = 1000, "msgid": 10, "subcode": 20, "data": [ "110.159.183.16", = "124.108.16.94", "2400:3700:50::2", "2400:3700:50::1", "2400:3700:51::" = ] } Many thanks. On Feb 11, 2013, at 9:55 AM, MRAB wrote: > You should keep reading until you get all need or the connection is > closed: >=20 > buf =3D b'' > while len(buf) < nbuf: > chunk =3D sock.recv(nbuf - len(buf)) >=20 > if not chunk: > break >=20 > buf +=3D chunk >=20 > --=20 > http://mail.python.org/mailman/listinfo/python-list