controlOut = null;
}
public void start() throws IOException
{
ServerSocket serverSocket;
InetAddress myAddress = InetAddress.getLocalHost();
byte[] address = myAddress.getAddress();
String portCommand = "PORT ";
serverSocket = new ServerSocket(0, 1);
// append each byte of our address (comma-separated)
for (int i = 0; i < address.length; i++)
{
portCommand = portCommand + (address[i] & 0xFF) + ",";
}
// append our server socket's port as two comma-separated
// hex bytes
portCommand = portCommand +
((serverSocket.getLocalPort() >>> 8)
& 0xFF) + "," + (serverSocket.getLocalPort() & 0xFF);
// issue PORT command
if (issueCommand(portCommand) == FTP_ERROR)
{
serverSocket.close();
throw new IOException("PORT");
}
// issue RETRieve command
if (issueCommand("RETR " + fileString) == FTP_ERROR)
{
serverSocket.close();
throw new IOException("RETR");
}
dataSocket = serverSocket.accept();
serverSocket.close();
}