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