Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #38692

Re: Python recv loop

Subject Re: Python recv loop
From Ihsan Junaidi Ibrahim <ihsan@grep.my>
Date 2013-02-11 23:08 +0800
References <B52841CC-778D-41AF-AFCC-05A5F9C26A92@grep.my> <51184F74.60902@mrabarnett.plus.com>
Newsgroups comp.lang.python
Message-ID <mailman.1657.1360595288.2939.python-list@python.org> (permalink)

Show all headers | View raw


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 <python@mrabarnett.plus.com> wrote:

> You should keep reading until you get all need or the connection is
> closed:
> 
>    buf = b''
>    while len(buf) < nbuf:
>        chunk = sock.recv(nbuf - len(buf))
> 
>        if not chunk:
>            break
> 
>        buf += chunk
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Python recv loop Ihsan Junaidi Ibrahim <ihsan@grep.my> - 2013-02-11 23:08 +0800

csiph-web