Home

Lectures

Assignments

Quizzes

Presentations

 

 

 

------Client Server Programming-------   

  Lectures:

LECTURE  1

 First week of Client Server Programming was very challenging and exciting, a new concept of  Socket programming was introduced. By using different techniques we were taught and practiced to create a simple client server application. After learning that, another challenging task was given, creating  a 3-tier application.

         Contents

·         Socket Programming

·         Client Server Connection

·         3-tier Application

  •  SOCKET PROGRAMMING:

 Communication over the network involves sockets for creating connections sockets connect to numbered communication ports. Java supports sockets with the Socket class. When a client wants to communicate with the server a new socket is created, IP address and port number is passed to it. On the server side a server socket is created, it accepts the client request and the communication starts on the port passed by the client program.

  •  CLIENT SERVER CONNECTION:

 We created a client program that connects to a server program, sends message, and gets a message back In this case, we have used the local host, which means both the server and the client will be on the same machine. However, you can use any DNS you like as long as you place the server script on the corresponding machine. Both the client and server should connect on the same port thus remember when selecting a port be careful that it is free.

  •  3-TIER APPLICATION:

 This application was a little different then the one created before. It involves 3 programs, the client, the middle server and the server, therefore its called 3-tier application. Database connectivity was established on server side. Client was suppose to generate a query, that query parameters were passed to the middle server then to the server. Server executes the query and fetches the result from the database. The record fetched from the database was passed to the middle server.

LECTURE  2

 In this week we learned and practiced multithreaded programming in java, and created a client server application. It was different then the one we created before, as  the  server side is capable of handling multi-client requests by using threads.  

Contents:

·         Threads

·         Multi-Server Client application

 THREADS:

 A thread is a stream of code execution, using threads, you can have your programs seemingly do several things at once. For example your code might be interacting with the user while also performing time-consuming tasks in the background. Separate threads don’t actually run at the same time, of course (unless you have a multiprocessor machine);in reality, each thread gets time slices on the same processor. The apparent result, however, is that various threads are executing at the same time, and that can be very impressive.

 MULTI-SERVER CLIENT APPLICATION:

 It was a simple, command line, multi-threaded echo server, which listens on fixed port 5000, no authentication was required. When any client sends a request for connection a new socket is created and a class ServerThread is invoked. ServerThread  is a subclass of Thread which override the run method of class Thread, and you can allocate and start an instance of that class. Whatever the client says, it is sent back to it. At client side, socket is created to connect to server port, data streams are initialized. Using those streams the client can write and read from the server.

 LECTURE  3

 Week four went really exciting and innovative, as we learned various methods and techniques to make effective and user friendly GUIs. Swings was the major topic, using database at the backend and handling different types of queries. We also learned and practiced how to create a port scanner by using threads on client side. 

Contents:

·         Swings

·         DataBase application in Swings

·         Port scanner 

SWINGS:

Swing is a set of packages built on top of the AWT that provides you with a great number of prebuilt classes(over 250 classes and 40 UI components).Beside the large array of components ins wings and the fact that they’re light weight, Swing introduces many other innovations. Here are some of the major ones: 

1.        Borders

2.        Graphics debugging

3.        East mouseless operation

4.        Tooltips

5.        Easy scrolling

6.        Pluggable look and feel

7.        New layout managers 

DATABASE APPLICATION IN SWINGS: 

This application is created using swing components, database is connected and various operations like Add, Delete, Update, Next and Previous can be performed.

       PORT SCANNER:

Port Scanner looks for the free port on server side. Threads are used on client side, each thread scans a new port and check if its free for communication. It is a simple application which does not require a heavy code.

LECTURE 4:

  • Smtp:

Simple Message transfer Protocol is used to send some data to the server.It uses port number 25.

The following pattern is followed to send data:

     MAIL FROM: ksm@paknet.com.pk

     Read server response

     RCPT TO: naaadi@hotmail.com

     Read server response

     DATA

     Read server response

     Any Message

     ……

     Read server response

     Connection closed

 

LECTURE 5:

  • POP RFC 1939

 Initially, the server host starts the POP3 service by listening on TCP port 110.  When a client host wishes to make use of the service, It establishes a TCP connection with the server host.  When the connection is established, the POP3 server sends a greeting.  The Client and POP3 server then exchange commands and responses (respectively) until the connection is closed or aborted. You can use BLueBottle.com as ip and port number 110.Its a RFC to retrieve mails.

This RFC follows the following pattern:

 Authentication:

     user     ahmz

     Pass      bahria

 Transaction:

 STAT:    gives the sum of octets of all mails

 LIST:      shows the size of a particular mail.

 RETR:     gives the data of the particular mail

 DELE      : Deletes the mail.

 Update:

 QUIT 

  • FTP  RFC 959
File Transfer Protocol uses the Telnet protocol on the control connection. It can work with prenhall.com as ip and 21 as port.

This RFC follows the following pattern:

 Authentication:

     user     anonymous

     Pass      email address

It listens on port numbers 192,168,150,80,14,178

 Transaction:

         CDUP - Change to Parent Directory

         SMNT - Structure Mount

         STOU - Store Unique

         RMD - Remove Directory

         MKD - Make Directory

         PWD - Print Directory

         SYST - System

 Update:     quit 

  • MIME 1.0 RFC 1521

 Multipurpose Internet Mail instruction is a RFC which is used to send data to the server.

 The following pattern is followed to send data:

 MAIL FROM: ksm@paknet.com.pk

 Read server response

 RCPT TO: naaadi@hotmail.com

 Read server response

 DATA

 Read server response

 From: Bahria <abc@bahria.edu.pk>

 To :FAST<abc2nu.adu.pk>

 Subject: Test mail

 MIME-VERSION 1.0

 Content-Type: multiport /mixed ,boundary=”Simple Boundary”

 Any Message

 ......

 Read server response

 Connection closed

 

LECTURE 6:

  • Http RFC 2616

The Hypertext Transfer Protocol (Http) is a request/response protocol. A client sends a request to the server in the form of a request method, URI, and protocol version, followed by a MIME-like message containing request modifiers, client information, and possible body content over a

Connection  with a server. The server responds with a status line, Including the message's protocol version and a success or error code, Followed by a MIME-like message containing server information, entity meta information, and possible entity-body content.

 ·         Servlets:

Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers. For example, a servlet may be responsible for taking data in an HTML order-entry form and applying the business logic used to update a company's order database. Servlets are to servers; applets are to browsers. Unlike applets, however, servlets have no graphical user interface. 

Servlet’s interface:

The central abstraction in the Servlet API is the Servlet interface. All servlets implement this interface, either directly or, more commonly, by extending a class that implements it such as HttpServlet.

Servlets-->Generic Servlet-->HttpServlet-->MyServlet.

The Servlet interface declares, but does not implement, methods that manage the servlet and its communications with clients. Servlet writers provide some or all of these methods when developing a servlet.

When a servlet accepts a call from a client ,it creates two objects:

ServeltRequest: which encapsulates the communication from the client to the server.

ServletResponse: which encapsulates the communication from the servlet back to the client.

ServletRequest and ServletResponse are interfaces defined by the javax.servlet package.

 

All Rights Reserved UQR pvt.ltd.