Differences between revisions 3 and 4
Revision 3 as of 2007-01-25 10:32:02
Size: 2357
Editor: nickcheng
Comment: 排版
Revision 4 as of 2007-01-25 10:36:27
Size: 2471
Editor: nickcheng
Comment:
Deletions are marked like this. Additions are marked like this.
Line 6: Line 6:
To communicate with the Internet, programs use objects known as sockets. The Python library supports sockets through module socket, as well as wrapping them into higher-level client-side modules, as covered in Chapter 19. To help you write server programs, the Python library also supplies higher-level modules to use as frameworks for socket servers. Standard and third-party Python modules and extensions also support asynchronous socket operations. This chapter covers socket, in "The socket Module" on page 521; server-side framework modules, in "The SocketServer Module" on page 528; asynchronous operation with standard Python library modules, in "Event-Driven Socket Programs" on page 533; and the bare essentials of the rich and powerful Twisted third-party package, in "The Twisted Framework" on page 539. To communicate with the Internet, programs use objects known as sockets. The Python library supports sockets through module '''socket''', as well as wrapping them into higher-level client-side modules, as covered in [:../Ch-19:Chapter 19]. To help you write server programs, the Python library also supplies higher-level modules to use as frameworks for socket servers. Standard and third-party Python modules and extensions also support asynchronous socket operations. This chapter covers '''socket''', in "[:../Ch-20.1:The socket Module]" on page 521; server-side framework modules, in "[:../Ch-20.2:The SocketServer Module]" on page 528; asynchronous operation with standard Python library modules, in "Event-Driven Socket Programs" on page 533; and the bare essentials of the rich and powerful '''Twisted''' third-party package, in "[:../Ch-20.3:The Twisted Framework]" on page 539.
Line 8: Line 8:
The modules covered in this chapter offer many conveniences compared to C-level socket programming. However, in the end, the modules rely on native socket functionality supplied by the underlying operating system. While it is often possible to write effective network clients by using just the modules covered in Chapter 19 without really needing to understand sockets, writing effective network servers most often does require some understanding of sockets. Thus, the lower-level module socket is covered in this chapter and not in Chapter 19, even though both clients and servers use sockets. The modules covered in this chapter offer many conveniences compared to C-level socket programming. However, in the end, the modules rely on native socket functionality supplied by the underlying operating system. While it is often possible to write effective network clients by using just the modules covered in [:../Ch-19:Chapter 19] without really needing to understand sockets, writing effective network servers most often does require some understanding of sockets. Thus, the lower-level module '''socket''' is covered in this chapter and not in [:../Ch-19:Chapter 19], even though both clients and servers use sockets.
Line 10: Line 10:
However, I cover only the ways in which module socket lets your program access sockets; I do not try to impart a detailed understanding of sockets, TCP/IP, and other aspects of network behavior independent of Python that you may need to make use of socket's functionality. To understand socket behavior in detail on any kind of platform, I recommend W. Richard Stevens's Unix Network Programming, Volume 1 (Prentice Hall). Higher-level modules are simpler and more powerful, but a detailed understanding of the underlying technology is always useful, and sometimes it can prove indispensable. However, I cover only the ways in which module '''socket''' lets your program access sockets; I do not try to impart a detailed understanding of sockets, TCP/IP, and other aspects of network behavior independent of Python that you may need to make use of '''socket''''s functionality. To understand socket behavior in detail on any kind of platform, I recommend W. Richard Stevens's Unix Network Programming, Volume 1 (Prentice Hall). Higher-level modules are simpler and more powerful, but a detailed understanding of the underlying technology is always useful, and sometimes it can prove indispensable.

翻译仅为个人学习,商业版权与此无关!::-- ["Roka"] TableOfContents

Chapter 20. Sockets and Server-Side Network Protocol Modules

To communicate with the Internet, programs use objects known as sockets. The Python library supports sockets through module socket, as well as wrapping them into higher-level client-side modules, as covered in [:../Ch-19:Chapter 19]. To help you write server programs, the Python library also supplies higher-level modules to use as frameworks for socket servers. Standard and third-party Python modules and extensions also support asynchronous socket operations. This chapter covers socket, in "[:../Ch-20.1:The socket Module]" on page 521; server-side framework modules, in "[:../Ch-20.2:The SocketServer Module]" on page 528; asynchronous operation with standard Python library modules, in "Event-Driven Socket Programs" on page 533; and the bare essentials of the rich and powerful Twisted third-party package, in "[:../Ch-20.3:The Twisted Framework]" on page 539. BRBR The modules covered in this chapter offer many conveniences compared to C-level socket programming. However, in the end, the modules rely on native socket functionality supplied by the underlying operating system. While it is often possible to write effective network clients by using just the modules covered in [:../Ch-19:Chapter 19] without really needing to understand sockets, writing effective network servers most often does require some understanding of sockets. Thus, the lower-level module socket is covered in this chapter and not in [:../Ch-19:Chapter 19], even though both clients and servers use sockets. BRBR However, I cover only the ways in which module socket lets your program access sockets; I do not try to impart a detailed understanding of sockets, TCP/IP, and other aspects of network behavior independent of Python that you may need to make use of socket's functionality. To understand socket behavior in detail on any kind of platform, I recommend W. Richard Stevens's Unix Network Programming, Volume 1 (Prentice Hall). Higher-level modules are simpler and more powerful, but a detailed understanding of the underlying technology is always useful, and sometimes it can prove indispensable. BRBR

讨论 Discussion

评译

PageComment2


  • ["技术文档分类"]

PythonInANutshell/Ch-20 (last edited 2009-12-25 07:18:13 by localhost)