File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes Event Drvien Client Server Programming Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Event Drvien Client Server Programming" Watch "Event Drvien Client Server Programming" New topic
Author

Event Drvien Client Server Programming

Neha Pa
Greenhorn

Joined: Jul 23, 2008
Posts: 11
Hi All,

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?

Not: I am using TCP/IP protocol.

Thanks in advance.

Neha
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8877
    
    8

Neha Pa wrote:
Not: I am using TCP/IP protocol.


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.
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

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.

apigee, a better way to API!
Maris Orbidans
Ranch Hand

Joined: Mar 08, 2004
Posts: 149
Joe Ess wrote:
There is no socket notification functionality in the standard API.


There is in NIO.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Event Drvien Client Server Programming