aspose file tools*
The moose likes Java in General and the fly likes DatagramPacket with more than one group Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "DatagramPacket with more than one group" Watch "DatagramPacket with more than one group" New topic
Author

DatagramPacket with more than one group

Jahar Heard
Greenhorn

Joined: Jan 09, 2010
Posts: 20
How can i add more than one group in DatagramPacket. I tryed with array like that..

but no success. When the array ends gives Exception java.lang.ArrayIndexOutOfBoundsException . So what is the deal here, can it be done without loop or with it, but the array to be looping throw some groups ? the str[i] contains bunch of a ip's like 255.0.0.1 and etc .
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Jahar Heard wrote:



Hi i dont know about the DataGramPacket technology. But can you try modifying the for loop like below and check?



Jahar Heard
Greenhorn

Joined: Jan 09, 2010
Posts: 20
Lol worked ... FIxed the array error, but does anyone has information about the Packets how can i send endless groups to them i mean endless loop with groups ?
Arun Chidam
Ranch Hand

Joined: May 08, 2006
Posts: 79
Jahar Heard wrote:Lol worked ... FIxed the array error, but does anyone has information about the Packets how can i send endless groups to them i mean endless loop with groups ?


what you mean by endless loop with group???
while(ture){
//will run endless, but why do you need to run endless loop?, please explain the business objective for your requirement which will help us to provide better solution
}


SCJP 1.4, SCWCD 1.4
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19004
    
  40

By group, I am assuming that you mean multicast group. Not sure of any other networking term with "group" in it; and related to datagram packets.

Even so, "datagrampacket with more than one group" doesn't make sense. Datagrams are put on transports (even multicast transports). There is no datagram packet with groups.

We definitely need more info here.
Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Jahar Heard
Greenhorn

Joined: Jan 09, 2010
Posts: 20
OK so here is the thing i'm trying to do. PHP client to client passing through java server. I can't figure it out how can i join a multicast group in java from php client socket.. just.. Any ideas, or something that is near to my thought.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19004
    
  40

Jahar Heard wrote:OK so here is the thing i'm trying to do. PHP client to client passing through java server. I can't figure it out how can i join a multicast group in java from php client socket.. just.. Any ideas, or something that is near to my thought.


Your followup question seems simple enough -- you want to communicate with another client. What have you tried so far with the java.net.MulticastSocket class? What you described should work -- just join the same multicast group as the PHP client, and as long as the switches and routers routes the datagrams, you should be able to send and receive.

Henry
 
Consider Paul's rocket mass heater.
 
subject: DatagramPacket with more than one group