File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Urgently Help/Guidance Required Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Urgently Help/Guidance Required" Watch "Urgently Help/Guidance Required" New topic
Author

Urgently Help/Guidance Required

Vrishal Likhite
Greenhorn

Joined: Nov 21, 2005
Posts: 18
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Urgently Help/Guidance Required