msoulier / tftpy

Pure Python TFTP library
http://tftpy.sf.net
MIT License
170 stars 120 forks source link

Timeout option issue #119

Open rajeshdgsb opened 3 years ago

rajeshdgsb commented 3 years ago

Hi, I see that the server accepts timeout as an optional param, with default value = 5sec (SOCK_TIMEOUT). In my understanding , when the client is downloading a file this should mean that if the server does not receive an ack within 'timeout' sec, its should retransmit the last acknowledged packet (RFC 2349) But, I saw that the server times out and resends the packet after 5sec irrespective of what the timeout is set to.

I looked into the code and in the TftpServer.listen(....) the following is used to listen for incoming packet: select.select(inputlist, [], [], SOCK_TIMEOUT) instead shouldn't it be this ?

select.select(inputlist, [], [], timeout)
Using SOCK_TIMEOUT in the above call basically makes the timeout parameter in the following call useless.

self.sessions[key] = TftpContextServer(raddress,
                                                               rport,
                                                               timeout,
                                                               self.root,
                                                               self.dyn_file_func,
                                                               self.upload_open)