OK im writing an FTP server/client and it works great...If the client only downloads one file. Heres the code that sends the file
public void sendFile(String dir, Socket sock2)
{
try
{
BufferedOutputStream send = new BufferedOutputStream(sock2.getOutputStream());
try
{
File g = new File(dir);
System.out.println(g.getPath());
FileInputStream in = new FileInputStream(g);
int c=0;
while((c = in.read()) != -1)
{
send.write(c);
}
send.close();
System.out.println("File Sent");
}
catch (IOException err) {}
}
catch (IOException err) {System.out.println(err);}
}
It sends the first file then closes the socket to complete the transfer (Otherwise file never finishes sendind) then when it gets called again it dosnt reopen the socket. I am now thinking I need to look into supporting mulitple clients. but basicly How to I reopen the Socket to send another File?