210 likes | 375 Views
CS335 Networking & Network Administration. Tuesday, May 25, 2010. Client-server. Network applications Protocol software cannot initiate contact with, or accept contact from a remote computer Two application programs must participate in any communication
E N D
CS335 Networking &Network Administration Tuesday, May 25, 2010
Client-server • Network applications • Protocol software cannot initiate contact with, or accept contact from a remote computer • Two application programs must participate in any communication • One application initiates the communication and the other accepts it • In the client-server paradigm, a server application waits passively for a client application to initiate communication
Characteristics of client/server • Client software • Is an arbitrary application program that becomes a client temporarily when remote access is needed, but also performs other computation locally • Is invoked directly by the user, and executes for only one session • Runs locally on a user’s personal computer • Actively initiates contact with the server • Can access multiple services as needed, but actively contacts one remote server at a time • Does not require special hardware or OS
Server programs • Special-purpose, privileged program dedicated to providing one service, but can handle multiple remote clients at one time • Is invoked automatically when a system boots, and continues to execute through many sessions • Runs on a shared computer • Waits passively for contact from arbitrary remote clients • Accepts contact from arbitrary clients, but offers a single service • Requires powerful hardware and a sophisticated OS also known as a server-class computer • Software technically is the server
Data flow • Information can pass in either or both directions between a client and server • Can be a series of request with response form the server • Can be a continuous flow of data from server as soon as client contacts
Client-server • TCP/IP stack as the transport protocol • For troubleshooting need to know what transport protocol is being used
Multiple services • Sufficient hardware resources • Network OS that allows multiple concurrent applications • Practical to run multiple server apps, but…
Multiple services • Groupwise • Follett library software • Winschool • Macschool • File server services • Mealtime • Filemaker pro • Open district – Oracle • Sophos • Antivirus server • Proxy server
Protocol port numbers • TCP uses 16-bit integer values to identify services • Assigns a unique protocol port number to each service • Both client and server specify the service identifier (port number) • Protocol software uses the identifier to direct each incoming request to the correct server software
Concurrency • A computer system that permits multiple application programs to execute at the same time • Multiple process, task, or thread • Concurrent server offers service to multiple clients without requiring clients to wait for other clients to finish
Dynamic server creation • Main server thread creates a new service thread for each new client connection • Service tread handles one request, then terminates • Main thread keeps the server alive waiting for requests
Transport protocols • Transport protocols assign an identifier to each client as well as to each service • Protocol software on server uses the combination of client and server identifiers to choose the correct copy of the concurrent server
Connection-oriented transport • Establish connection • Send data • Terminate • TCP
Connectionless transport • Application can send a message to any destination at any time • UDP • Client-server apps can use either approach • Can also offer both with the choice of transport left to the client
Sockets • Interface between an application program and the communication protocols in an OS is known as the Application Program Interface or API • The socket API is a de facto standard • A protocol standard might suggest an operation is needed to allow an application to send data, and the API specifies the exact name of the function and the type of each argument
Socket libraries • Socket functions are part of BSD UNIX • Other vendors started adding a socket API to their systems • Instead of modifying the OS, programmers added a socket library that provides the socket API • Socket library can provide apps with a socket API on systems that do not provide native sockets • When an app calls one of the socket procedures, control passes to a library routine that makes calls to the underlying OS
Sockets, descriptors, I/O • When an app creates a socket, the app is given a small integer descriptor used to reference the socket • If a system uses the same descriptor space for sockets and other I/O, a single application can be used for network communication as well as for local data transfer
Socket procedures • Create • Close • Bind • Listen • Accept • Connect • Send • Receive • Read • Write
Socket API routines • Socket API • The Socket API is the standard API for TCP/IP programming in the UNIX world. In the Windows world, the Winsock API is based on and shares a lot with the BSD Socket API. This makes conversion between the two fairly easy. • All the routines that application programmers would expect are available, including (but not limited to): • accept()bind()bindresvport()connect()dn_comp()dn_expand()endprotoent()endservent()gethostbyaddr()gethostbyname()getpeername()getprotobyname()getprotobynumber()getprotoent()getservbyname()getservent()getsockname()getsockopt()herror()hstrerror()htonl()htons()h_errlist()h_errno()h_nerr()inet_addr()inet_aton()inet_lnaof()inet_makeaddr()inet_netof()inet_network()inet_ntoa()
Socket API routines • ioctl()listen()ntohl()ntohs()recv()recvfrom()res_init()res_mkquery()res_query()res_querydomain()res_search()res_send()select()send()sendto()setprotoent()setservent()setsockopt()shutdown()socket() • The common daemons and utilities from the Internet will easily port or just compile in this environment. This makes it easy to leverage what already exists for your applications.
Client Server examples • Chapter 30