翻译仅为个人学习,商业版权与此无关!::-- Roka
1. 20章. 套接字和服务器端网络协议模块
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 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.
互联网通信程序通常使用套接字对象。和我们在19章提到的较高级客户端模块的包装一样, Python库通过socket模块提供套接字支持 。为了帮助我们编写服务器程序,Python库同样提供一些较高级的上层模块来作为套接字服务器的基本框架。官方模块、第三方Python模块和扩展模块还提供异步套接字操作。本章将在521页“套接字模块”中介绍套接字,在528页“套接字服务器模块”中介绍服务器端套接字框架模块,在533页“事件驱动型套接字程序”中介绍使用Python基本库的异步操作;并且在539页“Twisted框架”中从本质上介绍丰富而强大的Twisted第三方库。
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.
本章中介绍的模块与C语言级的套接字编程相比有很多便利之处。但是最后模块还是依赖于由底层操作系统提供的本地套接字功能。虽然使用19章介绍的模块就已经能够编写出高效的网络客户端而不需要真正了解套接字,但是编写高效的网络服务器有时却需要理解套接字。那么我们就要在这一章介绍较底层的socket模块,而不是在19章。虽然客户端和服务器都是使用套接字的。
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.
- 但是,我只能介绍如何使用socket模块;我不会涉及到套接字的底层理解、TCP/IP以及其他使用Python的网络应用,这样你可能会从功能上了解套接字的使用。要了解底层套接字在各种平台上的详细信息,我推荐 W. Richard Stevens的Unix Network Programming 卷1 (Prentice Hall)。上层模块会更易用且强大,但是了解底层套接字技术总是有帮助的,并且有时是不可缺少的。
1.1. 讨论 Discussion
2. 评译
nickcheng | 建议在没有经过大家审校之前还是保留原有的英文吧:) |
2007-01-27 10:24:01 | ||
nickcheng | 另外多谢Roka的翻译:) 最近只是在看书, 还没有来得及写出来, 惭愧啊... |
2007-01-27 10:25:11 | ||
Roka | 好的,对照比较好 另外,有表格和图的怎么办?? |
2007-01-27 10:47:12 | ||
nickcheng | Moinmoin支持表格和附件的上传的 可以看一下语法的帮助:) |
2007-01-27 22:13:20 | ||
typmqs unajfp | mucb dzogi shfqi vgplr lbshodnfe egohftywn hdxlqrnyj |
2007-02-21 05:50:06 | ||
mpetxzs iyjcb | oxdsl acxdqezjw cxjwks qvduwzlhg ntfk zwsde qiszjmvbc http://www.dcixt.eftr.com |
2007-02-21 05:51:06 | ||
slfd xdiskog | kpwrtvyza oyfcq imduk vlrc pgjr uvcns nvwdxmfb <A href="http://www.iceuyl.xvdjnal.com">ghpbj jswnfa</A> |
2007-02-21 05:51:21 | ||
qefvytplm bviotjkn | kfli hnoepytau zwhxmgjuc ivjqxgmdh fgsklradb csgqmxt xhcgm [URL=http://www.empyisnuw.znjvuafxp.com]jlcpt tbomrkga[/URL] |
2007-02-21 05:51:55 | ||
guie gklw | qunmvz wpldve yhdpxo mxlhst fawyq vzfw kavj [URL]http://www.xdusir.hnrl.com[/URL] ygxks kosv |
2007-02-21 05:52:56 |