Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS490T Advanced Tablet Platform Applications Network Programming Evolution.

Similar presentations


Presentation on theme: "CS490T Advanced Tablet Platform Applications Network Programming Evolution."— Presentation transcript:

1 CS490T Advanced Tablet Platform Applications Network Programming Evolution

2 Introduction Programming network applications has evolved with programming languages Programming network applications has evolved with programming languages Tools have been created at each step to make distributed applications as easy as writing local applications. Tools have been created at each step to make distributed applications as easy as writing local applications.

3 BSD Sockets Network sockets were introduced in the UNIX Berkeley Standard Distributions (BSD UNIX) Network sockets were introduced in the UNIX Berkeley Standard Distributions (BSD UNIX) They provided a common API to the TCP/IP stacks They provided a common API to the TCP/IP stacks They were written generically enough to be used for other protocols different than TCP/IP. That made them awkward to use. They were written generically enough to be used for other protocols different than TCP/IP. That made them awkward to use.

4 BSD Sockets They were very successful because they provided a portability path for network applications. They were very successful because they provided a portability path for network applications. An application written with sockets can be easily ported to other UNIX systems or Windows. An application written with sockets can be easily ported to other UNIX systems or Windows. Sockets provide a Sockets provide a –Stream interface for TCP –Message based interface for UDP

5 TCP Sockets In the stream interface for TCP reading/writing to the other network peer will be similar to reading/writing to a file or pipe. In the stream interface for TCP reading/writing to the other network peer will be similar to reading/writing to a file or pipe.

6 TCP Sockets Server Side The server does: The server does: Ms = Socket(…) – creates socket Bind(…) – bind socket to a specific port Listen(…) – puts socket in listen mode While(1) { ss = accept(ms, …) // Accept connection read(ss, …) // Read request write(ss, …) // Write reply write(ss, …) // Write reply}

7 TCP Sockets Client Side The client does the following The client does the following s= socket(…) // Creat socket bind(s, …) // Bind socket to a port connect(s) // Connect to server write(s, …) // Write request read(s,…) // Read reply close(s)

8 Disadvantage of Socket Programming Too complicated Too complicated Error prone. So many calls, so many possibilities of error. Error prone. So many calls, so many possibilities of error. Every communication detail has to be explicitly programmed. Every communication detail has to be explicitly programmed.

9 Examples of Socket Applications Lots of applications are implemented using sockets: Lots of applications are implemented using sockets: –FTP, SMTP, Finger, HTTP, …

10 Remote Procedure Calls (RPC) Abstract the network communication as a procedure call. Abstract the network communication as a procedure call. A program uses a method exported remotely as if it were local. A program uses a method exported remotely as if it were local. The interface of the procedure is described in a RPC description language. The interface of the procedure is described in a RPC description language. The RPC description is processed with an RPC preprocessor that generates code for the client and the server. The RPC description is processed with an RPC preprocessor that generates code for the client and the server.

11 RPCs Client Side For the client side the code generated includes procedure stubs that For the client side the code generated includes procedure stubs that –Defines the procedure with the same arguments –Connects to the remote server –Takes the arguments and send them through the network (marshaling). –Waits for a reply –Copies the result to the result of the procedure and returns. –The programmer uses these stubs transparently as if the procedures were executed locally.

12 RPC Server Side The RPC processor generates for the server a dispatcher server code that The RPC processor generates for the server a dispatcher server code that –Initializes the sockets –Starts the serving loop waiting for a new request –When a request arrives it copies the data from the network to the argument buffer (unmarshalling) –It invokes the procedure corresponding to the RPC id. –It sends the results of the procedure to the other side (marshaling) –The programmer of the server only implements the procedures themselves. The communication part is generated by the RPC processor.

13 RPC Issues The representation of numbers, strings etc. may be different in different machines. The representation of numbers, strings etc. may be different in different machines. In sockets that is not usually a problem since the communication is textually based in ASCII format. In sockets that is not usually a problem since the communication is textually based in ASCII format. In RPCs the data is sent in binary form. This saves processing time since no ASCII to decimal conversion is necessary but may cause problems in machines of different architecture. In RPCs the data is sent in binary form. This saves processing time since no ASCII to decimal conversion is necessary but may cause problems in machines of different architecture. The RPC generator also generates filters that convert the binary data if necessary. The RPC generator also generates filters that convert the binary data if necessary.

14 RPC Issues In SUN RPC, the data is always converted to an External Data Representation (XDR) before sending. In SUN RPC, the data is always converted to an External Data Representation (XDR) before sending. The data is converted back to the representation of the local machine when received. The data is converted back to the representation of the local machine when received. In RPC’s arguments and results can be passed only by value (int, string, float etc) In RPC’s arguments and results can be passed only by value (int, string, float etc) It is not possible to send data by reference (Object *this) so it is not easy to write object oriented programs. It is not possible to send data by reference (Object *this) so it is not easy to write object oriented programs.

15 RPC Examples The best known implementation of RPC’s is SUNRPC The best known implementation of RPC’s is SUNRPC SUNRPC defines an RPC language and provides an RPC processor called RPCgen SUNRPC defines an RPC language and provides an RPC processor called RPCgen Applications such as NFS, rusers, mount, yellow pages are implemented in SUN RPC. Applications such as NFS, rusers, mount, yellow pages are implemented in SUN RPC.

16 Remote Method Invocation (RMI) It was created because of the limitations that RPC has handling references to objects. It was created because of the limitations that RPC has handling references to objects. In RMI a reference to a remote object is represented as a pointer to a local representation to the object called “Proxy”. In RMI a reference to a remote object is represented as a pointer to a local representation to the object called “Proxy”. A method invocation to the proxy is forwarded to the remote object. A method invocation to the proxy is forwarded to the remote object. Invoking methods in the proxy will be transparent and it will look like we are invoking methods in the object as if it were local. Invoking methods in the proxy will be transparent and it will look like we are invoking methods in the object as if it were local.

17 Proxy Creation/Deletion When a reference to a remote object is received, a new proxy is created. When a reference to a remote object is received, a new proxy is created. When the reference to the remote object is no longer needed, the proxy is deleted. When the reference to the remote object is no longer needed, the proxy is deleted. Some cooperation from the local garbage collector is needed to identify unneeded proxies. Some cooperation from the local garbage collector is needed to identify unneeded proxies. Remote objects are removed when tere are no longer remote proxies pointing to it. Remote objects are removed when tere are no longer remote proxies pointing to it.

18 RMI Examples The proxy code is generated by a processor from a RMI description. The proxy code is generated by a processor from a RMI description. Some examples of RMI are: Java RMI, CORBA Orbix, DCOM, Modula 3 Remote Objects. Some examples of RMI are: Java RMI, CORBA Orbix, DCOM, Modula 3 Remote Objects.


Download ppt "CS490T Advanced Tablet Platform Applications Network Programming Evolution."

Similar presentations


Ads by Google