Hi , this will be a long one...

Im making a ftp server, briefley like this..
class server
listen on serversocket....
on new connection accept make instance to Client handler.
Each connect client has it's own handler instance witch is a Thread...

in the client handler run method..
while connected...
Read of ftp commands (implemented following the ftp standard)

every thing works good, lots of clients can connect.
Problem accours when a client wants to download / upload large files.

when it get the RETR ftp command it start a instance thread to a class upload. Here i open a new socket and sets it to the conected client adress and transfer port, sets transfermode to 'I'. Inside the read / write loop it just hangs up, i just can't see why
i've been working with this problem for some time week now

Here is a part of the upload class extending thread

class Upload
 private Socket socket;
 private Client  client;
 private String  filename;
 private int       port;

public Upload(Client client, String file, int fport){
 this.port  = fport;
 this.client = client;
 this.filename = file;

InetSocketAddress SocketAddress = new  InetSocketAddress(client.getSocket().getInetAddress(), port));
socket = new Socket(client.getSocket().getInetAddress(), port);
}catch(Exception e){System.out.println("Error");}

public void Run 
  if sendmode = aschii then..... this one works just fine
 else send image / binary

// Binary send

 int  buffersize = 4096*2;
 byte buff[]      = new byte[buffersize];
 int  bytesread   = 0;

 readdata  = new BufferedInputStream (new    FileInputStream(filename));
 writedata = new BufferedOutputStream(new DataOutputStream(socket.getOutputStream()));

 while((bytesread = readdata.read(buff,0,buffersize)) >=0){ 
    writedata .write(buff,0, bytesread);
    writedata .flush();

close sockets and streams....exit thread
I've found out that it sends all types of files, as long as they are under ~32Kb of size. With bigger files it just hangs up. I have been debugging the filenames, ports and adresses seem to match. I think the fault is in my othner client class i will take a look in that. But if someone can se a error here please notify me.

Any suggestions ??
Best regards to ya all, thanks for any help.