commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank Delporte (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (NET-604) TFTP send & receive don't have progress indication
Date Mon, 03 Apr 2017 11:33:41 GMT

    [ https://issues.apache.org/jira/browse/NET-604?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15953324#comment-15953324
] 

Frank Delporte commented on NET-604:
------------------------------------

[~sebb@apache.org] FYI, just got latest version updated in my project and could use these
values perfectly as intended. Thanks for the merge!

> 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)

Mime
View raw message