Hi Guys,
I am doing a project on SearchEngine for lan...The basic idea is that using my program a user will share any file on system and after that an xml file is generated which is having the names of all the shared files.Now all such Xml files generated on a particular system will have to be sent to every user who is connected via lan ...For sending the file,v used the idea that first the client machine will multicast that they want to search a file....and it would request all connected to send their XML files.Problem is that I get an error of Address already in use when i run my code...The following is my code...

Code for server
import java.io.*;
import java.net.*;
import java.util.*;

public class MulticastServer {


public static void main(String[] args) throws IOException {


String received=null;
BufferedReader in=null;

MulticastSocket socket = new MulticastSocket(4446);
InetAddress address = InetAddress.getByName("230.0.0.1");
socket.joinGroup(address);

DatagramPacket packet;

// get a few quotes


byte[] buf = new byte[256];
packet = new DatagramPacket(buf, buf.length);
socket.receive(packet);
InetAddress address1 = packet.getAddress();
int port = packet.getPort();
received = new String(packet.getData(), 0, packet.getLength());
System.out.println(received);
System.out.println("Packet Recieved Successfully");
socket.leaveGroup(address);
socket.close();


try {
in = new BufferedReader(new FileReader("write.xml"));
} catch (FileNotFoundException e) {
System.err.println("Could not open quote file. Serving time instead.");
}

while(in.readLine()!=null)
{
String str=in.readLine();
byte[] buf1=new byte[512];
buf1=str.getBytes();
DatagramSocket socket1 = new DatagramSocket(port);
DatagramPacket packet1=new DatagramPacket(buf1,buf1.length,address1,port);

socket1.send(packet1);
socket1.close();
}

}
}

Code for client

import java.io.*;
import java.net.*;
import java.util.*;

public class MulticastClient{



public MulticastServerThread() throws IOException {
super("MulticastClient");
}

public void run() {

try {
byte[] buf = new byte[256];

// construct quote
String dString = null;


dString = "request";
buf = dString.getBytes();

// send it
InetAddress group = InetAddress.getByName("230.0.0.1");
DatagramPacket packet = new DatagramPacket(buf, buf.length, group, 4446);
socket.send(packet);
socket.receive(packet);
System.out.println("Thnx");

} catch (IOException e) {
e.printStackTrace();
moreQuotes = false;

}
socket.close();
}
}


Let me explain the code...the client sends a packet of request to server...Server chks it and sends the XML file to the client...I m getting an error of "ADDRESS ALREADY IN USE:CANNOT BIND"...plzz help