• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Urgently Help/Guidance Required

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The programme is in Rmi, i want an ordered list of hostnames in a multicast group.The PROBLEM is that i want to receive the server name on client and send client name to the server


i am sendin my rmi implimentation file please take a look....



public void send() throws RemoteException
{
try
{//****************************************

//used to get the computer name

//****************************************

InetAddress address;
address=InetAddress.getLocalHost();
String name=address.getHostName();
System.out.println("name="+name);
//*****************************************

//Building socket to send the name

//****************************************
MulticastSocket socket=new MulticastSocket(6000);
DatagramPacket packet;
byte buffer[] = new byte[256];
address=InetAddress.getByName("230.0.0.1");
packet= new DatagramPacket(buffer, buffer.length,address, 9013);
socket.send(packet);
System.out.println("Name Sent");

//****************************************

}
catch(Exception e)
{
System.out.println("error in data send");
}


}


public void receive()throws RemoteException
{
try
{
InetAddress address= InetAddress.getByName("230.0.0.1");
MulticastSocket socket;
DatagramPacket packet;
byte buffer[] = new byte[256];
System.out.println("in receive");
//***************************************

//Receive the names of others

//****************************************
String data="No data";
socket= new MulticastSocket(9013);
packet =new DatagramPacket(buffer, buffer.length);
socket.joinGroup(address);
System.out.println("group joined");
socket.receive(packet);
data=new String(packet.getData());
System.out.println("The Recieved Data =="+data);
}
catch(Exception e)
{
System.out.println("error in data receive");
}


}
}

Am stuck up in this part of code above and urgent answer is expected.

thanking you in advance

vrishal
reply
    Bookmark Topic Watch Topic
  • New Topic