哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter3

Chapter 3: Client Software Design Chapter goal: ■ Algorithm and issues Concurrency in client Client examples 哈工大计算机学院李全龙 Network Application Development Client Software Design 1
哈工大计算机学院 李全龙 Network Application Development Client Software Design 1 Chapter 3: Client Software Design Chapter goal: Algorithm and issues Concurrency in client Client examples

Chapter 3: Client Software Design Chapter goal: Algorithm and issues Concurrency in client Client examples 哈工大计算机学院李全龙 Network Application Development Client Software Design 2
哈工大计算机学院 李全龙 Network Application Development Client Software Design 2 Chapter 3: Client Software Design Chapter goal: Algorithm and issues Concurrency in client Client examples

Learning algorithm instead of details An application that uses TCP/IP must specify many details about the desired communication Knowing the low-level details of all possible socket functions and their exact parameters does not provide programmers with an understanding of how to build well-designed, distributed program general understanding of the functions used for network communication is important If the programmer knows what the program should do finding ouf how to do it is straightforward Although programmers need to understand the conceptual capabilities of the protocol interface, they should concentrate on learning about ways to structure communicating programs instead of memorizing the details of a particular interface 哈工大计算机学院李全龙 Network Application Development Client Software Design 3
哈工大计算机学院 李全龙 Network Application Development Client Software Design 3 Learning algorithm instead of details An application that uses TCP/IP must specify many details about the desired communication. Knowing the low-level details of all possible socket functions and their exact parameters does not provide programmers with an u n d erstandi ng of how to build well-designed, distributed program. General underst anding of the functions used for network communication is important. If the programmer knows what the program should do, finding out how to do it is straightforward. Although programmers need to understand the conceptual capabilities of the protocol interface, they should concentrate on learning about ways to structure communicating programs instead of memorizing the details of a particular interface

Client architecture Clients are conceptually simpler than servers Most client does not explicitly handle concurrent interaction with multiple servers Most client executes as a conventional app program Most client does not need to enforce protections 哈工大计算机学院李全龙 Network Application Development Client Software Design
哈工大计算机学院 李全龙 Network Application Development Client Software Design 4 Client architecture Clients are conceptually simpler than servers. Most client does not explicitly handle concurrent interaction with multiple servers. Most client executes as a conventional app program. Most client does not need to enforce protections

Identify a server Several methods to find a server s Ip address and protocol port number Domain name or ip address as a constant in program Requiring user to identify: From stable storage Using a separate protocol to find Allowing the user to specify a server address when invoking client software makes the client program more general and makes it possible to change server ocations Building client that accepts a server address as an argument makes it easy to build extended versions of the software that use other ways to find the server address 哈工大计算机学院李全龙 Network Application Development Client Software Design 5
哈工大计算机学院 李全龙 Network Application Development Client Software Design 5 Identify a server Several methods to find a server’s IP address and protocol port number: Domain name or IP address as a constant in program; Requiring user to identify; From stable storage; Using a separate protocol to find; Allowing the user to specify a server address when invoking client software makes the client program more general and makes it possible to change server locations. Building client that accepts a server address as an argument makes it easy to build extended versions of the software that use other ways to find the server address

Parsing an address argument a Client can use domain name or ip address to identify the server machine To determine whether the user has specified a name or an address the client scans the argument Client sometimes need additional information such as protocol port Two arguments merlin. cs, purdue. edu sm打 Single argument merlin. cs. purdue. edu: smtp Consistency is important 哈工大计算机学院李全龙 Network Application Development Client Software Design 6
哈工大计算机学院 李全龙 Network Application Development Client Software Design 6 Parsing an address argument Client can use domain name or IP address to identify the server machine. To determine whether the user has specified a name or an address, the client scans the argument. Client sometimes need additional information, such as protocol port. Two arguments: merlin.cs.purdue.edu smtp Single argument: merlin.cs.purdue.edu:smtp Consistency is important

Looking up a domain name A client must specify the address of a server using structure of sockaddr in Doing so means converting an address in dotted decimal notation or domain name into a 32-bit IP address Function inet addr takes an ASCII string that contains a dotted decimal address and returns the equivalent IP address in binary Function gethostbyname takes an ASCII string that contains the domain name for a machine, and returns the address of a hostent structure that contains among other strings the host's ip address in binal The hostent structure is declared in include file winsock.h 哈工大计算机学院李全龙 Network Application Development Client Software Design 7
哈工大计算机学院 李全龙 Network Application Development Client Software Design 7 Looking up a domain name A client must specify the address of a server using structure of sockaddr_in. Doing so means converting an address in dotted decimal notation (or domain name) into a 32-bit IP address. Function inet_addr takes an ASCII string that contains a dotted decimal address and returns the equivalent IP address in binary. Function gethostbyname takes an ASCII string that contains the domain name for a machine, and returns the address of a hostent structure that contains, among other strings, the host’s IP address in binary. The hostent structure is declared in include file winsock.h

hostent structure stuct hostent char Far为 name / official host name“ char far* far* h aliases: /*other aliases short h addrtype /*address type short h lengty, address leng char far* far h addr list: /list of address #define h addr h addr listlo Fields that contain names and addresses must be lists because of multiple interfaces h addrrefer to the first location in the host address list A program can use h_addr as if it were a field of structure hostent 哈工大计算机学院李全龙 Network Application Development Client Software Design
哈工大计算机学院 李全龙 Network Application Development Client Software Design 8 hostent structure stuct hostent { char FAR* h_name; /*official host name */ char FAR* FAR* h_aliases; /*other aliases */ short h_addrtype; /*address type */ short h_lengty; /*address length */ char FAR* FAR* h_addr_list; /*list of address */ }; #define h_addr h_addr_list[0] Fields that contain names and addresses must be lists because of multiple interfaces. h_addr refer to the first location in the host address list. A program can use h_addr as if it were a field of structure hostent

Example for gethostbyname stuct hostent为hptr; char *examplenam="merlin. cs. purdue. edu if (hptr=gethostbyname(example) /* IP address is now in hptr>h_addr*/ else /*error in name-handle it*/ Successfully call, gethostbyname returns a pointer to a valid hostent struture. Otrerwise Returns a NULL pointer 哈工大计算机学院李全龙 Network Application Development Client Software Design 9
哈工大计算机学院 李全龙 Network Application Development Client Software Design 9 Example for gethostbyname stuct hostent *hptr; char *examplenam=“merlin.cs.purdue.edu”; if (hptr=gethostbyname(example)){ /* IP address is now in hptr->h_addr*/ }else { /*error in name-handle it*/ } Successfully call, gethostbyname returns a pointer to a valid hostent struture. Otrerwise, Returns a NULL pointer

Looking up a well-known port by name Look up the protocol port for specific service a geTservbyname Two arguments A string that specifies the desired service A string that specifies the protocol being used Returns a pointer to a structure of type Servent Defined in include file winsock. h 哈工大计算机学院李全龙 Network Application Development Client Software Desi
哈工大计算机学院 李全龙 Network Application Development Client Software Design 10 Looking up a well-known port by name Look up the protocol port for specific service. getservbyname Two arguments: A string that specifies the desired service A string that specifies the protocol being used Returns a pointer to a structure of type servent. Defined in include file winsock.h
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter3-6.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter2.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter2-6.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter1new.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter1new-6.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter1.pdf
- 陕西国防学院:《电子商务概论》第十章 电子商务系统的建设.pps
- 陕西国防学院:《电子商务概论》第六章 网络营销.pps
- 陕西国防学院:《电子商务概论》第九章 电子商务安全.pps
- 陕西国防学院:《电子商务概论》第八章 电子商务的法律规范.pps
- 陕西国防学院:《电子商务概论》第四章 电子商务支付系统.pps
- 陕西国防学院:《电子商务概论》第七章 电子商务在其他领域的应用.pps
- 陕西国防学院:《电子商务概论》第一章 电子商务概述.pps
- 陕西国防学院:《电子商务概论》第三章 电子商务的应用框架与交易模式.pps
- 陕西国防学院:《电子商务概论》第五章 物流管理.pps
- 陕西国防学院:《电子商务概论》第二章 网络技术基础.pps
- 陕西国防学院:《电子商务概论》序言.pps
- 《计算机软件技术基础》ppt电子课件.ppt
- 《Microsoft Project 2002 教学手册》讲义.pdf
- 《高级软件工程》学习资料(英文版)Software System Safety.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter4-6.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter4.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter5-6.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter5.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter6-6.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter6.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter7-6.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 NAD-chapter7.pdf
- 哈尔滨工业大学:《网络应用开发》英文版 网络开发与应用实验指导书.pdf
- 台北科技大学:《计算机网络》(英文版) NP04 0 Network Programming.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 1 CONTENTS.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 11 Introduction.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 12 CONTENTS.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 15 Client Server model.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 16 Socket API.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 16 Client Software Design.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 16 multi proto.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 16 multi services.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 16 server.ppt
- 台北科技大学:《计算机网络》(英文版) NP04 16 server ex.ppt