1
TFTP sendfile을 :요청 응답에 잘못된 소스 포트 (69)가 있습니다. 나는이 TFTP DOS 자바에서 TFTP 클라이언트로 명령을 전송 실행 트링있어
tftp -i 192.168.1.13 put file1.romz file1.romz
그것은 호스트로 파일 file1.romz를 전송하는 것을 의미
: 바이너리 방식으로, 192.168.1.13을하고 이름을 변경 file1.romz에 도착하면 파일. TFTP DOS command 정보
import java.io.FileInputStream;
import java.io.IOException;
import java.net.SocketException;
import java.net.UnknownHostException;
import org.apache.commons.net.tftp.TFTP;
import org.apache.commons.net.tftp.TFTPClient;
public class TFTPClientToSend {
public final static void main(String[] args) {
boolean closed;
int transferMode = TFTP.BINARY_MODE;
String hostname, localFilename, remoteFilename;
TFTPClient tftp;
// Get host and file arguments
hostname = "192.168.1.13";
localFilename = "file1.romz";
remoteFilename = "file1.romz";
// Create our TFTP instance to handle the file transfer.
tftp = new TFTPClient();
// We want to timeout if a response takes longer than 60 seconds
tftp.setDefaultTimeout(60000);
// Open local socket
try {
tftp.open();
} catch (SocketException e) {
System.err.println("Error: could not open local UDP socket.");
System.err.println(e.getMessage());
System.exit(1);
}
// We haven't closed the local file yet.
closed = false;
// We're sending a file
FileInputStream input = null;
// Try to open local file for reading
try {
input = new FileInputStream(localFilename);
} catch (IOException e) {
tftp.close();
System.err.println("Error: could not open local file for reading.");
System.err.println(e.getMessage());
System.exit(1);
}
// Try to send local file via TFTP
try {
tftp.sendFile(remoteFilename, transferMode, input, hostname, 69);
} catch (UnknownHostException e) {
System.err.println("Error: could not resolve hostname.");
System.err.println(e.getMessage());
System.exit(1);
} catch (IOException e) {
System.err.println(
"Error: I/O exception occurred while sending file.");
System.err.println(e.getMessage());
System.exit(1);
} finally {
// Close local socket and input file
tftp.close();
try {
input.close();
closed = true;
} catch (IOException e) {
closed = false;
System.err.println("Error: error closing file.");
System.err.println(e.getMessage());
}
}
if (!closed) {
System.exit(1);
}
}
}
필드는 정확하지만, 나는 다음과 같은 오류 메시지가 얻을 :
이Error: I/O exception occurred while sending file.
Incorrect source port (69) in request reply.
TFTP에 UDP 포트는 공식적으로 69 Windows 방화벽이다 해제 및 TFTP이다
이
코드입니다 Lantronix Server는 TFTP를 통해 새 방화벽을 업데이트 할 수 있습니다. Java는 임의의 포트를 사용하여 문자열의 첫 번째 프레임에서 데이터를 보냅니다. 이것이 내가이 오류 메시지를 가지고있는 이유라고 생각합니다. 소스 포트를 어떻게 바꿀 수 있습니까? 아니면이 오류를 일으키는 또 다른 문제입니까?미리 감사드립니다.