DatagramSocket ds = new DatagramSocket(this.my_listening_port);
byte[] rcv_data = new byte[1024];
DatagramPacket dp = new DatagramPacket(rcv_data,rcv_data.length);
String rcv_data_string[] = new String[no_of_child_node];
for(int i=0; i<no_of_child_node; i++)
{
ds.receive(dp);
rcv_data_string[i] = new String(dp.getData());
System.out.println("result of child " + i + ": " + rcv_data_string[i]);
}
String query_result = new String();
query_result += this.self_node_id;
for(int i=0; i<no_of_child_node ; i++)
{
System.out.println("result of child " + i + ": " + rcv_data_string[i]);
query_result = query_result.concat(rcv_data_string[i]);
}
ds.close();
System.out.println("Final result of me and child : " + query_result);
sending_result_to_parent(query_result);
Output :
result of child 0: t2
result of child 1: t5
result of child 2: t3t1
result of child 0: t2
result of child 1: t5
result of child 2: t3t1
Final result of me and child : t4t2
my expected final result : Final result of me and child : t4t2t5t3t1
What is the problem with above code ? So can anyone kindly tell what can be the problem?