Summary: Observer, Sockets
The java.util.Observer/.Obervable interface provide a fundamental observation design pattern in Java. It is an abstraction that lets a number of client objects (the observers) be notified whenever a certain object or resource (the observable) changes in some way. The observers implement the Observer interface, which specifies that notification causes an Observer object’s update() method to be called.
-The classes of java.net fall into two general categories: the Sockets API for working with low-level Internet protocols and higher-level, web-oriented APIs that work with uniform resource locators (URLs).
-Sockets are the lowest-level tool in the general networking toolbox—you can use sockets for any kind of communications between client and server or peer applications on the Net, but you have to implement your own application-level protocols for handling and interpreting the data.
-The java.net packag supports a simplified, object-oriented socket interface that makes network communications considerably easier
- Sockets,DatagramSocket
-Socket class, which uses a connection-oriented and reliable protocol.
- DatagramSocket class, which uses a connectionless, unreliable protocol. A connectionless protocol is like the postal service. Applications can send short messages to each other, but no end-to-end connection is set up in advance and no attempt is made to keep the messages in order.
-In most cases, an application acting as a server creates a ServerSocket object and waits, blocked in a call to its accept() method, until a connection arrives. When it arrives,the accept() method creates a Socket object that the server uses to communicate with the client. A server may carry on conversations with multiple clients at once; in this case, there is still only a single ServerSocket , but the server has multiple Socket objects—one associated with each client as above shown
-Client Sample
-Server Sample