[
https://issues.apache.org/jira/browse/NET-604?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sebb resolved NET-604.
----------------------
Resolution: Fixed
Thanks for the suggestion.
Applied with minor changes:
- use long for the counts
- use public getters and make the fields private
URL: http://svn.apache.org/viewvc?rev=1782077&view=rev
Log:
NET-604 TFTP send & receive don't have progress indication
Modified:
commons/proper/net/trunk/src/changes/changes.xml
commons/proper/net/trunk/src/main/java/org/apache/commons/net/tftp/TFTPClient.java
> TFTP send & receive don't have progress indication
> --------------------------------------------------
>
> Key: NET-604
> URL: https://issues.apache.org/jira/browse/NET-604
> Project: Commons Net
> Issue Type: Improvement
> Components: TFTP
> Affects Versions: 3.5
> Reporter: Frank Delporte
> Labels: newbie, patch
> Fix For: 3.6
>
>
> Now there is no way to know if TFTP is progressing, so I think with a quick
> fix and two extra public variables this can be solved.
> Attached my patch for this.
> A more extended functionality with events might be better but will require
> more rework
> Index: TFTPClient.java
> ===================================================================
> --- TFTPClient.java (revision 1773211)
> +++ TFTPClient.java (working copy)
> @@ -64,6 +64,12 @@
>
> /*** The maximum number of timeouts allowed before failing. ***/
> private int __maxTimeouts;
> +
> + /*** The number of bytes received in the ongoing download. ***/
> + public int totalBytesReceived = 0;
> +
> + /*** The number of bytes sent in the ongoing upload. ***/
> + public int totalBytesSent = 0;
>
> /***
> * Creates a TFTPClient instance with a default timeout of
> DEFAULT_TIMEOUT,
> @@ -134,7 +140,7 @@
>
> beginBufferedOps();
>
> - dataLength = lastBlock = hostPort = bytesRead = 0;
> + dataLength = lastBlock = hostPort = bytesRead = totalBytesReceived =
> 0;
> block = 1;
>
> if (mode == TFTP.ASCII_MODE) {
> @@ -277,6 +283,8 @@
> ack.setBlockNumber(lastBlock);
> sent = ack;
> bytesRead += dataLength;
> +
> + totalBytesReceived += dataLength;
> } // First data packet less than 512 bytes signals end of stream.
>
> while (dataLength == TFTPPacket.SEGMENT_SIZE);
> @@ -385,7 +393,7 @@
>
> beginBufferedOps();
>
> - dataLength = lastBlock = hostPort = bytesRead = totalThisPacket = 0;
> + dataLength = lastBlock = hostPort = bytesRead = totalThisPacket =
> totalBytesSent = 0;
> block = 0;
> boolean lastAckWait = false;
>
> @@ -538,15 +546,18 @@
> /* this will be our last packet -- send, wait for ack, stop
> */
> lastAckWait = true;
> }
> +
> data.setBlockNumber(block);
> data.setData(_sendBuffer, 4, totalThisPacket);
> sent = data;
> +
> + totalBytesSent += totalThisPacket;
> }
> while ( totalThisPacket > 0 || lastAckWait );
> // Note: this was looping while dataLength == 0 || lastAckWait,
> // which was discarding the last packet if it was not full size
> // Should send the packet.
> -
> +
> endBufferedOps();
> }
>
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)