File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Event Drvien Client Server Programming

 
Neha Pa
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1638
IntelliJ IDE Java MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Maris Orbidans
Ranch Hand
Posts: 149
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic