title: Python implementation for Stop and Wait Algorithm
body: <p>I am trying to implement a stop and wait algorithm. i have a problem in implementing the timeout at the sender. While waiting for an ACK from reciever, i am using the recvfrom() function. However this makes the program idle, and i can't follow the timeout to re transmit.</p>
  
  <p><strong>here is my code:</strong> </p>
  
  <pre><code>import socket
  
  import time
  
  mysocket=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
  
  
  while True:
  
  
     ACK= " "
  
      userIn=raw_input()
      if not userIn : break
      mysocket.sendto(userIn, ('127.0.0.01', 88))     
      ACK, address = mysocket.recvfrom(1024)    #the prog. is idle waiting for ACK
      future=time.time()+0.5   
      while True:
              if time.time() &gt; future:
                      mysocket.sendto(userIn, ('127.0.0.01', 88))
                      future=time.time()+0.5
              if (ACK!=" "):
                      print ACK
                      break 
  mysocket.close()
  </code></pre>