# HG changeset patch # Parent 5649394b92b363c05655a744083800e11b4d8812 diff --git a/Doc/howto/sockets.rst b/Doc/howto/sockets.rst --- a/Doc/howto/sockets.rst +++ b/Doc/howto/sockets.rst @@ -23,14 +23,15 @@ working. It doesn't cover the fine points (and there are a lot of them), but I hope it will give you enough background to begin using them decently. -I'm only going to talk about INET sockets, but they account for at least 99% of -the sockets in use. And I'll only talk about STREAM sockets - unless you really -know what you're doing (in which case this HOWTO isn't for you!), you'll get -better behavior and performance from a STREAM socket than anything else. I will -try to clear up the mystery of what a socket is, as well as some hints on how to -work with blocking and non-blocking sockets. But I'll start by talking about -blocking sockets. You'll need to know how they work before dealing with -non-blocking sockets. +I'm only going to talk about :abbr:`INET (InterNET)` sockets, but they +account for at least 99% of the sockets in use. And I'll only talk +about STREAM sockets - unless you really know what you're doing (in +which case this HOWTO isn't for you!), you'll get better behavior and +performance from a STREAM socket than anything else. I will try to +clear up the mystery of what a socket is, as well as some hints on how +to work with blocking and non-blocking sockets. But I'll start by +talking about blocking sockets. You'll need to know how they work +before dealing with non-blocking sockets. Part of the trouble with understanding these things is that "socket" can mean a number of subtly different things, depending on context. So first, let's make a @@ -43,10 +44,10 @@ History ------- -Of the various forms of IPC (*Inter Process Communication*), sockets are by far -the most popular. On any given platform, there are likely to be other forms of -IPC that are faster, but for cross-platform communication, sockets are about the -only game in town. +Of the various forms of :abbr:`IPC (Inter Process Communication)`, +sockets are by far the most popular. On any given platform, there are +likely to be other forms of IPC that are faster, but for +cross-platform communication, sockets are about the only game in town. They were invented in Berkeley as part of the BSD flavor of Unix. They spread like wildfire with the Internet. With good reason --- the combination of sockets @@ -73,7 +74,7 @@ exchanges). What happens in the web server is a bit more complex. First, the web server -creates a "server socket". :: +creates a "server socket":: #create an INET, STREAMing socket serversocket = socket.socket( @@ -171,7 +172,7 @@ a client can detect the end of the reply by receiving 0 bytes. But if you plan to reuse your socket for further transfers, you need to realize -that *there is no "EOT" (End of Transfer) on a socket.* I repeat: if a socket +that *there is no* :abbr:`EOT (End of Transfer)` *on a socket.* I repeat: if a socket ``send`` or ``recv`` returns after handling 0 bytes, the connection has been broken. If the connection has *not* been broken, you may wait on a ``recv`` forever, because the socket will *not* tell you that there's nothing more to @@ -337,7 +338,7 @@ In C, coding ``select`` is fairly complex. In Python, it's a piece of cake, but it's close enough to the C version that if you understand ``select`` in Python, -you'll have little trouble with it in C. :: +you'll have little trouble with it in C:: ready_to_read, ready_to_write, in_error = \ select.select(