Forums Register Login

Event Drvien Client Server Programming

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

Joe Ess wrote:
There is no socket notification functionality in the standard API.



There is in NIO.
It's never done THAT before. Explain it to me tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1749 times.
Similar Threads
How server can send notification without sending n e req.
B&S suncertify.properties
Expected behaviour of server when no network connection?
Fail-Over notification to clients,
Regarding java I/O
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:30:21.