This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Distributed Java and the fly likes How to maintain several UDP paths? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "How to maintain several UDP paths?" Watch "How to maintain several UDP paths?" New topic
Author

How to maintain several UDP paths?

Shiham Nawaz
Greenhorn

Joined: Aug 04, 2006
Posts: 11
Hi,
I'm coding a chat application (using UDP)which communicates through a chat server. I need to uniquely identify the communication path between the workstations involved in a end-to-end chat(through the server)session.

Pls advise me in this regard, as to how i can identify a particular communication session in UDP

Thank you.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
If I understand the question correctly, you can use the getSocketAddress() method of the DatagramPacket object to uniquely identify the source.
Bill
Shiham Nawaz
Greenhorn

Joined: Aug 04, 2006
Posts: 11
Hi,
yes, this is correct incase i'm using just a 2 tier arhitecture and the communication is between the client and server. But my case is, a client communicates with another client through the server. And i need the server to monitor a particular session as there will be many "client to client" sessions through the server.
In TCP this could be easily done, but i want to use UDP, and i cant seem to uniquely maintain a particular session. I cant seem to get the logic behind this.
I need to recognize a particular session because, i want to dynamically add more clients to a particular session(something like conferencing).

Pls help me with this regard
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
Each message packet of bytes must contain routing information so the server can send it to the correct client(s).

You need to come up with a design for a standard fixed block of data that will be transmitted with each packet in addition to the variable chat data. Since this is UDP, each packet must stand alone AND the application can not break if a packet is lost.

Taking the anthropomorphic approach, imagine that you are the server getting a single slip of paper at a time - what do you need to know to send it to the right recipient?

It is an interesting problem, please let us know what you come up with.

Bill
 
Don't get me started about those stupid light bulbs.
 
subject: How to maintain several UDP paths?