Client Software Design Algorithms and Issues Chuan-Ming liu Computer Science and Information Engineering Spring 2004, NTUt TAIWAN CSIE NTUT Taiwan
CSIE, NTUT, Taiwan 1 Client Software Design Algorithms and Issues Chuan-Ming Liu Computer Science and Information Engineering Spring 2004, NTUT TAIWAN
Client Software Design a How applications become clients by initiating communication a How applications use TCP or UDP protocols to contact a server How they use socket calls to interact with the protocols CSIE NTUT Taiwan
CSIE, NTUT, Taiwan 2 Client Software Design ◼ How applications become clients by initiating communication ◼ How applications use TCP or UDP protocols to contact a server ◼ How they use socket calls to interact with the protocols
Learning algorithms Instead of Details Learn know-what instead of know -how first a After knowing what to do, finding out how to do is straightforward CSIE NTUT Taiwan
CSIE, NTUT, Taiwan 3 Learning Algorithms Instead of Details ◼ Learn know-what instead of know-how first ◼ After knowing what to do, finding out how to do is straightforward
Client Architecture a Client applications are simpler than server applications No concurrent interaction Most client software executes as a conventional application a Dont need to enforce protection CSIE NTUT Taiwan
CSIE, NTUT, Taiwan 4 Client Architecture ◼ Client applications are simpler than server applications ◼ No concurrent interaction ◼ Most client software executes as a conventional application ◼ Don’t need to enforce protection
Identifying servers location Have the server 's domain name or ip address as constants when program is compiled a Using address makes client software faster and less dependent on local computing environment no flexibility Using a generic name for the server and an alias to the domain name system for that name Improvement Obtain information from stable storage Can not execute program unless the file is available CSIE NTUT Taiwan 5
CSIE, NTUT, Taiwan 5 Identifying Server’s location ◼ Have the server’s domain name or IP address as constants when program is compiled ◼ Using address makes client software faster and less dependent on local computing environment – no flexibility ◼ Using a generic name for the server and an alias to the domain name system for that name – improvement ◼ Obtain information from stable storage ◼ Can not execute program unless the file is available
Identifying servers location a Use a separate protocol to find a server Works in a small. local environment The dynamic property makes additional complexity and broadcast traffic on network Ask users to identify Avoid unnecessary complexity Makes the client software general Eliminates dependency ■ Most flexible Approach taken depends on services CSIE NTUT Taiwan
CSIE, NTUT, Taiwan 6 Identifying Server’s location ◼ Use a separate protocol to find a server ◼ Works in a small, local environment ◼ The dynamic property makes additional complexity and broadcast traffic on network ◼ Ask users to identify ◼ Avoid unnecessary complexity ◼ Makes the client software general ◼ Eliminates dependency ◼ Most flexible ◼ Approach taken depends on services
Parsing an Address Argument a Specify arguments on command line when invoking a client program Each argument consists of a character string a Client uses an argument's syntax to interpret Its meaning ■ Example: Domain name: csie ntut. edu. tw IP address:140.124.180.1 CSIE NTUT Taiwan 7
CSIE, NTUT, Taiwan 7 Parsing an Address Argument ◼ Specify arguments on command line when invoking a client program ◼ Each argument consists of a character string ◼ Client uses an argument’s syntax to interpret its meaning ◼ Example: ◼ Domain name: csie.ntut.edu.tw ◼ IP address: 140.124.180.1
Parsing an Address Argument a Additional information beyond the servers machine, or IP address can also be specified Example: (two arguments) cSie ntut. edu. tw smtp Csie ntut. edu. tw: smtp a Keep consistency with the local system CSIE NTUT Taiwan
CSIE, NTUT, Taiwan 8 Parsing an Address Argument ◼ Additional information beyond the server’s machine, or IP address can also be specified ◼ Example: (two arguments) ◼ csie.ntut.edu.tw smtp ◼ Csie.ntut.edu.tw:smtp ◼ Keep consistency with the local system
Looking up a Domain Name a Client needs to specify the address of a server a There are two forms in address argument ■ Domain name IP address(dotted decimal a Converting IP address to 32-bit binary representation is trivial Converting from a domain name require more effort CSIE NTUT Taiwan
CSIE, NTUT, Taiwan 9 Looking up a Domain Name ◼ Client needs to specify the address of a server ◼ There are two forms in address argument ◼ Domain name ◼ IP address (dotted decimal) ◼ Converting IP address to 32-bit binary representation is trivial ◼ Converting from a domain name require more effort
Looking up a Domain Name a Socket APi includes library routines, inet addr and gethostbyname to perform the conversion ■ inet addr; Takes dotted decimal address(in AScID and returns the ip address in binary a gethostbyname Takes the domain name and returns the address of a hostnet structure containing the Ip address in binary CSIE NTUT Taiwan 10
CSIE, NTUT, Taiwan 10 Looking up a Domain Name ◼ Socket API includes library routines, inet_addr and gethostbyname to perform the conversion ◼ inet_addr: Takes dotted decimal address (in ASCII) and returns the IP address in binary ◼ gethostbyname: Takes the domain name and returns the address of a hostnet structure containing the IP address in binary