|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectverinec.adaptation.snmp.tftpserver.Download
public class Download
Class responsible for managing the download process for TFTP service. We are the server, so this handles sending a file to a client.
Most of the source was taken from
www.it.rit.edu/~netsyslb/vksf522/class_examples/Day09_TFTPServer/Download.pdf
I removed the gui part.
| Nested Class Summary | |
|---|---|
private class |
Download.Listener
Private class that listens on a socket to receive datagrams. |
| Field Summary | |
|---|---|
private long |
bytesToSend
# of bytes left to download. |
private InetAddress |
clientAddress
the address of the server. |
private int |
clientPort
port to contact server on (69 per default). |
private DatagramPacket |
dgram
unparsed TFTP packet. |
private static int |
DOWNLOADING
State: Currently downloading. |
private static int |
ENDINGDL
State: Just finishing downloading. |
private DataInputStream |
fistream
input stream for reading the downloaded file. |
private String |
fp
|
private byte[] |
lastBlock
last block sent. |
private int |
lastBlockNo
block # of last block sent. |
private DatagramPacket |
lastPacket
last packet sent (for resends). |
private String |
lastPacketDesc
description of last packet sent (for logs). |
private Download.Listener |
listener
socket listener for incoming packets. |
private String |
localDirName
name of the local download directory. |
private String |
localName
name of the file. |
private Logger |
logger
debugging. |
private DatagramSocket |
socket
socket used to communicate with server. |
private int |
state
state of the download. |
private TFTPPacket |
tftp
parsed packet. |
private Timer |
timer
timer used for resends. |
private int |
timerCount
number of times the timer has expired. |
(package private) ActionListener |
timerExpired
|
| Constructor Summary | |
|---|---|
Download(DatagramPacket pkt,
TFTPPacket tftp,
String localDirName)
Creates a Download instance for downloading data |
|
| Method Summary | |
|---|---|
private void |
doACK(TFTPPacket pkt)
|
private void |
doERROR(TFTPPacket pkt)
|
private void |
doRRQ()
|
private void |
endDownload()
|
private void |
processPacket(DatagramPacket pkt)
|
void |
resendPacket()
Resends last sent packet if an error occured with sending of data. |
private void |
sendError(int code)
|
private void |
sendNextBlock()
|
private void |
sendPacket(DatagramPacket pkt)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private String fp
private Logger logger
private int state
private static final int DOWNLOADING
private static final int ENDINGDL
private DatagramPacket dgram
private TFTPPacket tftp
private String localDirName
private String localName
private InetAddress clientAddress
private int clientPort
private DataInputStream fistream
private int lastBlockNo
private byte[] lastBlock
private long bytesToSend
private Timer timer
private int timerCount
private DatagramPacket lastPacket
private String lastPacketDesc
private DatagramSocket socket
private Download.Listener listener
ActionListener timerExpired
| Constructor Detail |
|---|
public Download(DatagramPacket pkt,
TFTPPacket tftp,
String localDirName)
Download instance for downloading data
pkt - Unparsed TFTP packettftp - Parsed TFTP packetlocalDirName - Local download directoryTFTPPacket| Method Detail |
|---|
private void sendNextBlock()
public void resendPacket()
private void sendError(int code)
private void sendPacket(DatagramPacket pkt)
throws IOException
IOExceptionprivate void endDownload()
private void processPacket(DatagramPacket pkt)
private void doRRQ()
private void doACK(TFTPPacket pkt)
private void doERROR(TFTPPacket pkt)
|
Copyright © 2005 Verinec, DIUF | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||