Server side push
I have a project regarding network programming, and encountering a problem now.
The situation as follows:
I got a server program which make a server socket and listen to a dedicated/fixed port for clients connection. Suppose there is client connecting to our server, server will create a thread to serve for the client and sending data through the socket, It's seem find!!
Due to it is a real time system, we need to implement that the server will send out the same data every 1 mintue to all clients who are connected to the server. That mean all the clients should received the same data every 1 minute. So i think server side push technology should be implemented.
But I don't know how to broadcast the data to client in java, anyone can help?
Is it not possible to have a scenario where the client side has an applet that
sends requests to the server at specific intervals, indicating the clients latest update,
and the server side sends the latest update back if required ?
Thanks sjalle first!
If clients make request to receive the data from our server, there will be a case that different clients receive different data. It is because it is a real time system, data may change in a short period(maybe 1 to 2 minutes), so suppose all the clients should make request at the same time, but it is difficult to ensure this.
Perhaps you need a fast connection, and if the clients need different data depending on:
- their last data exchange
- their user authentication
- the state of the info (from both sides)
you should have a 'housekeeping' system that track this info, you may need a
database, which I am sure you already have (according to your description).
I've done similar stuff (synchronizing a databse on a lan) but you will have to give
me more info so I can be more specific.
Essentially, what your asking for is a multicast mechanism (broadcast messages to many clients). Have you looked at java.net.MulticastSocket?
iPush should meet your needs
Indeed, what you describe is a real time data distribution system. Such a system should be built with push technology.
Originally Posted by Ahsai
I think iPush Server is what you need. It also supports J2ME for MIDP2.0 and Flash.
The Vender's Site
They also provide demos developed with flash, you may surf their site and find them.
Are you the iPush spokesman. I think he wants to implement it himself...
Can this be setup so only the server can send messages??
When one sends a message to a multicast group, all subscribing recipients to that host and port receive the message (within the time-to-live range of the packet, see below). The socket needn't be a member of the multicast group to send messages to it.
When a socket subscribes to a multicast group/port, it receives datagrams sent by other hosts to the group/port, as do all other members of the group and port. A socket relinquishes membership in a group by the leaveGroup(InetAddress addr) method. Multiple MulticastSocket's may subscribe to a multicast group and port concurrently, and they will all receive group datagrams.
Currently applets are not allowed to use multicast sockets.
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL