This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I need to develope an event drvien Client Server application.
The requirement is whenevr connection/data is available then event should get fired. Ex: When client request for connection that should be notified to the server & user of server will decide whether to accept or decline that connection request.On accepting it ,when client sends data to server,data available notification should be sent to user of the server. And server in turn will send response back to Client.
Is there any inbuilt API of socket programming which notifies the server when data is available on the port from the client? Same as when data is available on Serial port for RS232,DATA_AVAILABLE event has been generated by JVM. On similar lines is there any Java's inbuit API for the notification?
Then what are you using? UDP?
There is no socket notification functionality in the standard API. The usual thing to do is establish a persistent socket connection with threads listening at either end for messages. Have a look at this tutorial for the basics.
An alternative may be RMI, which provides a handy abstraction of the network as remote objects. It's much easier to use than plain sockets when doing application programming, and one can easily implement Observable-style event handlers using it.
I am not sure whether you are looking at Selector provided as part of Java nio.
Selector follows a non-blocking event based mechanism to inform the listeners of events like data available, ready to accept, etc.