I still have trouble with the messaging. What i now did was to create a new thread for every connected socket as well as for every now outputstream.
package ftp;
import java.io.DataOutputStream;
import java.io.IOException;
public class MultiIO implements Runnable{
private DataOutputStream dos;
public MultiIO(DataOutputStream stream) {
dos = stream;
System.out.println("Set OutputStream.");
}
@Override
public void run() {
try {
dos.writeBytes("220");
dos.flush();
System.out.println("tried once");
} catch (IOException e) {
System.exit(-1);
}
}
}
The trouble now is that the FileZilla client won't get the 220 message.
here is the new socket handling class. i kinda copied it from the oracle page.
package ftp;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.net.SocketException;
public class MultiConnection implements Runnable{
private Socket cSocket;
public MultiConnection(Socket client) {
cSocket = client;
System.out.println("Connected!");
}
@Override
public void run() {
OutputStream os = null;
DataOutputStream dos = null;
try {
os = cSocket.getOutputStream();
dos = new DataOutputStream(os);
} catch (SocketException es) {
es.printStackTrace();
} catch (IOException e) {
System.exit(-1);
}
MultiIO mio;
mio = new MultiIO(dos);
Thread thio = new Thread(mio);
thio.start();
}
}