1 / 13

Client-server interactions in Mobile Applications

Client-server interactions in Mobile Applications. Example client-server app: 1) client reads line from standard input ( inFromUser stream) , sends to server via socket ( outToServer stream) 2) server reads line from socket 3) server converts line to uppercase, sends back to client

cleary
Download Presentation

Client-server interactions in Mobile Applications

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Client-server interactions in Mobile Applications

  2. Example client-server app: 1) client reads line from standard input (inFromUser stream) , sends to server via socket (outToServer stream) 2) server reads line from socket 3) server converts line to uppercase, sends back to client 4) client reads, prints modified line from socket (inFromServer stream) Socket programming with TCP Client process client TCP socket

  3. create socket, connect to hostid, port=x create socket, port=x, for incoming request: clientSocket = Socket() welcomeSocket = ServerSocket() TCP connection setup wait for incoming connection request connectionSocket = welcomeSocket.accept() send request using clientSocket read request from connectionSocket write reply to connectionSocket read reply from clientSocket close connectionSocket close clientSocket Client/server socket interaction: TCP Server (running on hostid) Client

  4. XML-RPC • remote procedure call protocol, created in 1998 • specification and a set of implementations, allowing procedure calls over the Internet • calls are transported using HTTP, and encoded in XML. • simple security model, can authenticate through HTTP/HTTPS

  5. Allows one method of serialization • Still in use, although newer technologies exist; JSON-RPC, SOAP and others. • www.xmlrpc.com

  6. Disadvantages • XML can be slow and cumbersome in transporting and processing messages • Calls can be made with plain XML instead; XML-RPC doesn't add any additional value

  7. Server: Apache XML-RPC Servlet http://ws.apache.org/xmlrpc/server.html Implementations: Client: Android XML-RPC • Thin, but complete XML-RPC library • http://code.google.com/p/android-xmlrpc/

  8. SOAP • Simple Object Access Protol: is a protocol specification for exchanging structured information in the implementation of Web Services in computer networks.

  9. SOAP

  10. SOAP • Advantage • Allow for the use of different transport protocols (HTTP as a transport protocol, but other protocols such as JMS and SMTP are also usable) • Since the SOAP model tunnels fine in the HTTP get/response model, it can tunnel easily over existing firewalls and proxies. • Canextend the existing infrastructure. • Disadvantage • Since SOAP bases on XML format, it require lots of resource for parsing and processing XML file (especially for large XML file). • SOAP is very verbose, and contains lots of overhead.  Not the best choice for data exchange with mobile devices.

  11. JSON JavaScript Object Notation – language independent specification of interchanging data in human-readable format. • In contrast with XML-RPC and SOAP it allows for bidirectional communication between client and server (like peers) and for multiple calls. • Data introduced in key:value pair format. • More economical than XML in terms of data size, but has less readability. • Android has JSONArray, JSONObject, JSONStringer and JSONTokener objects for parsing this format.

  12. Protocol Buffers Protocol Buffers– language independent data-serialization format developed by Google. This protocol is usually applied in server-to-server interactions. • Is significant faster and smaller than XML. • Type of messages is defined in .proto files. • Message is small logical record of a pairs of names and values. • Transmitted information is encoded into binary format. • Google provide necessary tools for binding this protocol with C++, Java and Python.

  13. Comparison of protocols “Using Internet data in Android applications” by Michael Galpin, IBM 2010, http://www.ibm.com/developerworks/opensource/library/x-dataAndroid/index.html

More Related