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


Groups > comp.lang.python > #36427

Re: what’s the difference between socket.send() and socket.sendall() ?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <phihag@phihag.de>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:skip:s 10': 0.05; 'exception.': 0.07; 'python': 0.09; 'blocking': 0.09; 'high- level': 0.09; 'requested.': 0.09; 'sockets': 0.09; 'throws': 0.09; 'cc:addr:python-list': 0.10; 'value.': 0.15; 'cc:name:python list': 0.16; 'filename:fname piece:signature': 0.16; 'low-level': 0.16; 'occurs.': 0.16; 'subject:between': 0.16; 'tcp': 0.16; 'wrote:': 0.17; 'basically': 0.17; 'bytes': 0.17; 'otherwise,': 0.20; 'doc': 0.22; 'sends': 0.22; 'cc:2**0': 0.23; '(this': 0.24; 'pass': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'error': 0.30; 'received:192.168.2': 0.34; 'method': 0.36; 'does': 0.37; 'sure': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'most': 0.61; 'between': 0.63; 'bothered': 0.65; 'subjectcharset:utf-8': 0.72; 'subject::': 0.83; 'what\xe2\x80\x99s': 0.84
Date Tue, 08 Jan 2013 13:42:07 +0100
From Philipp Hagemeister <phihag@phihag.de>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:10.0.11) Gecko/20121122 Icedove/10.0.11
MIME-Version 1.0
To iMath <2281570025@qq.com>
Subject Re: what’s the difference between socket.send() and socket.sendall() ?
References <tencent_59902ADC44E92FA26D58910B@qq.com>
In-Reply-To <tencent_59902ADC44E92FA26D58910B@qq.com>
X-Enigmail-Version 1.4
OpenPGP id=FAFB085C
Content-Type multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enig434ECFCC9BA1A76C3CB3D648"
Cc Python List <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.272.1357650581.2939.python-list@python.org> (permalink)
Lines 48
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1357650581 news.xs4all.nl 6942 [2001:888:2000:d::a6]:46172
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:36427

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

socket.socket.send is a low-level method and basically just the
C/syscall method send(3) / send(2). It can send less bytes than you
requested.

socket.socket.sendall is a high-level Python-only method that sends the
entire buffer you pass or throws an exception. It does that by calling
send until everything has been sent or an error occurs.

If you're using TCP with blocking sockets and don't want to be bothered
by internals (this is the case for most simple network applications),
use sendall.

Otherwise, use send and make sure to read and process its return value.

- Philipp

On 01/07/2013 11:35 AM, iMath wrote:
> what’s the difference between socket.send() and socket.sendall() ?
> 
> It is so hard for me to tell the difference between them from the python doc
> 
> so what is the difference between them ?
> 
> and each one is suitable for which case ?
> 

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


Thread

Re: what’s the difference between socket.send() and socket.sendall() ? Philipp Hagemeister <phihag@phihag.de> - 2013-01-08 13:42 +0100

csiph-web