UNO CSCI 8556 - Network Programming and Applications

Unformatted text preview:

CSCI 4550/8556 Computer NetworksIntroductionNetwork CommunicationClient-Server ComputingAddressing Internet ApplicationsCommunication ParadigmAn Example Application Program InterfaceExample API OverviewAn Intuitive Look at the APIA Trivial ExampleAPI Definition – Data TypesAPI Definition – await_contactAPI Definition – make_contactAPI Definition – appname_to_appnumAPI Definition – cname_to_compAPI Definition – sendAPI Definition – recvAPI Definition – recvlnAPI Definition – send_eofThe ECHO ApplicationAn Important ObservationThe CHAT ApplicationThe WEB ApplicationCSCI 4550/8556Computer NetworksComer, Chapter 3:Network Programming and ApplicationsIntroductionUse of a network requires programs (and systems) that are “network-aware.”Some applications are usually provided with machines (e.g. web clients, e-mail clients, file sharing).New custom applications must use the interface (API) to the network facilities provided by the system.We will look at a simple API and three sample applications (both the client and the server).Network CommunicationNetworks are the mechanisms that transmit data from one point to another.Logically, networks are (or should be) passive, and do not understand, act on, or modify the data being moved.There are two ends of a network communication, each associated with an application program that understands the generation and interpretation of the data being moved across the network.Client-Server ComputingThe two applications that communicate using a network must locate each other.Typically, one application (the server) starts and then waits for the other application (the client) to contact it.This arrangement is usually called the client-server paradigm, or just client-server computing.The client must, of course, be able to locate the server for this arrangement to work.Addressing Internet ApplicationsEach network server application has a two-part address of the form (computer,application).The computer part of the address identifies the particular computer on which the application is running. This can be provided in symbolic (e.g. apollo.unomaha.edu) or numeric (e.g. 137.48.1.12) form.The application part of the address identifies the particular application. It, too, can be provided symbolically or numerically.When transmitted on a network, the (computer,application) address is always sent in binary.Communication ParadigmMost Internet applications follow this basic sequence of operations for communication:The server starts first, and waits for contact from a client.The client contacts the server by specifying its location and requesting communication.The client and the server exchange messages.After they finish, the client and server each send an end-of-file to terminate communication.Functions are provided in the class library on apollo to perform each of these tasks.An Example Application Program InterfaceThe term “application program interface,” or API, is used to describe the set of operations available (in a particular programming domain) to a programmer.The simplified API presented in the textbook hides much of the complexity in network programming, but also doesn’t provide the richness of the usual networking API. We will see more details in later chapters.Example API OverviewOperation Meaningawait_contact used by server to wait for a contactmake_contact used by client to contact a servercname_to_comp translate a computer name to anequivalent internal binary valueappname_to_appnum translate a program name to anequivalent internal binary valuesend used by client or server to send datarecv used by client or server to receive datasend_eof used by client or server after all datahas been sent.An Intuitive Look at the APIThe application actions usually follow this pattern:The server calls await_contact to wait for contact from a client. The client calls make_contact to establish the connection. [The server is said to be blocked until the contact is made.]Once contact is made, the applications use send and recv to exchange data. [The protocol dictates when each application sends or receives.]Once the data exchange is complete, the client or the server terminates the connection by calling send_eof. The other application detects the termination of the communication when recv returns 0.A Trivial ExampleAPI Definition – Data TypesThere are three data types (in addition to the usual integer, character, and real data types) used in the API:appnum: a binary value used to identify an application [this is really a port number].computer: a binary value used to identify a computer [this is really an Internet Protocol address, or IP address.]connection: a value used to identify one endpoint of a connection between a client and a server [normally this identifies a socket data structure].API Definition – await_contactA server calls await_contact to wait for a contact from a client. The function expects one argument of type appnum, and returns a connection which is then used in send, recv, and send_eof functions.connection await_contact (appnum a)API Definition – make_contactA client calls m ake_contact to establish contact with a server. The arguments identify the computer on which the server is running, and the application number to be contacted. The function returns a connection used for send, recv, and send_eof by the client.connection make_contact (computer c, appnum a)API Definition – appname_to_appnumThis function is used to translate from a predefined human-readable name [character string] to a binary application number. Standard application names are defined in the /etc/services file on a UNIX system. It takes a string argument and returns the binary application number.appnum appname_to_appnum (char *name)API Definition – cname_to_compThis function translates a symbolic computer name (cname) to the equivalent binary form (which is returned) of type computer.computer cname_to_comp (char *cname)API Definition – sendSend arranges to transmit data (a sequence of n bytes in a char array buf) over an established connection c, returning the number of bytes actually transmitted. The last argument is always 0 in this simplified API.int send (connection c, char *buf,int n, 0)API Definition – recvRecv receives at most n bytes of data from a connection c, placing it in a char array b uf, and returning the number of bytes received and stored. Recv will return 0 only when the end of file is reached, and a negative


View Full Document

UNO CSCI 8556 - Network Programming and Applications

Download Network Programming and Applications
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Network Programming and Applications and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Network Programming and Applications 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?