本書第二部分講述的是在Wi n 3 2平臺(tái)上的Wi n s o c k編程。對(duì)于眾多的基層網(wǎng)絡(luò)協(xié)議,
Wi n s o c k是訪問它們的首選接口。而且在每個(gè)Wi n 3 2平臺(tái)上,Wi n s o c k都以不同的形式存在著。
Wi n s o c k是網(wǎng)絡(luò)編程接口,而不是協(xié)議。它從U n i x平臺(tái)的B e r k e l e y(B S D)套接字方案借鑒了
許多東西,后者能訪問多種網(wǎng)絡(luò)協(xié)議。在Wi n 3 2環(huán)境中,Wi n s o c k接口最終成為一個(gè)真正的
“與協(xié)議無關(guān)”接口,尤其是在Winsock 2發(fā)布之后。
本章專門講解編寫成功網(wǎng)絡(luò)應(yīng)用程序時(shí)所需的基本知識(shí)和A P I調(diào)用。通過上一章的學(xué)習(xí),
大家已知道從Wi n s o c k地址機(jī)和這些機(jī)器上的服務(wù),可以很容易地訪問協(xié)議。在這一章里,
我們打算討論如何從網(wǎng)絡(luò)上的一臺(tái)機(jī)器到另一臺(tái)機(jī)器建立連接,以及如何收發(fā)數(shù)據(jù)
本附錄介紹一些新的A P I函數(shù),有了這些函數(shù),便可在自己的計(jì)算機(jī)上對(duì)I P協(xié)議統(tǒng)計(jì)情況
進(jìn)行查詢和管理。它們有助于獲得下面的能力:
■ I p c o n f i g . e x e(或適用于微軟Windows 95的Wi n i p c f g . e x e):顯示I P配置信息,允許釋放
和更新D H C P分配的I P地址。
■ N e t s t a t . e x e:顯示T C P連接表、U D P監(jiān)聽者表以及I P協(xié)議統(tǒng)計(jì)情況。
■ R o u t e . e x e:顯示并處理網(wǎng)絡(luò)路由表。
■ A r p . e x e:顯示并修改供“地址解析協(xié)議”(A R P)使用的I P到物理地址翻譯表。
加密算法
Test Driver for Crypto++, a C++ Class Library of Cryptographic Primitives:
- To generate an RSA key
cryptest g
- To encrypt and decrypt a string using RSA
cryptest r
- To calculate MD5, SHS, and RIPEMD-160 message digests:
cryptest m file
- To encrypt and decrypt a string using DES-EDE in CBC mode:
cryptest t
- To encrypt or decrypt a file
cryptest e|d input output
- To share a file into shadows:
cryptest s <pieces> <pieces-needed> file
(make sure file has no extension, if you re running this under DOS)
- To reconstruct a file from shadows:
cryptest j output file1 file2 [....]
- To gzip a file:
cryptest z <compression-level> input output
- To gunzip a file:
cryptest u input output
- To run validation tests:
cryptest v
- To run benchmarks:
cryptest b [time for each benchmark in seconds]