title: UDP Pinger Assignment
body: <p>I have been trying to code a UDP client/server in python (as seen at bottom). 
  The code works and runs. But, I believe there is something wrong with the line: </p>
  
  <pre><code>    try:
          data, server = client_socket.recvfrom(1024) **# THIS LINE** 
          end = time.time()
          elapsed = end - start
          print(f'{data} {pings} {elapsed}')
  </code></pre>
  
  <p>When I run the code, it prints out the counter, the current time, and "REQUEST TIMED OUT" ten times as I would like it to. I have no idea why! I did so much research and tried other people's code but none of which are working! Please help! </p>
  
  <p>Server:</p>
  
  <pre><code>import random
  from socket import *
  
  serverSocket = socket(AF_INET, SOCK_DGRAM)
  serverSocket.bind(('', 12000))
  
  while True:
      rand = random.randint(0, 10)    
      message, address = serverSocket.recvfrom(1024)
      message = message.upper()
  
      if rand &lt; 4:
          continue
      serverSocket.sendto(message, address)
  </code></pre>
  
  <p>Client: </p>
  
  <pre><code>import time
  import socket
  
  count = 0
  
  for pings in range(10):
      client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
      client_socket.settimeout(1.0)
      message = b'test'
      address = ("127.0.0.1", 12000)
  
      start = time.time()
      client_socket.sendto(message, address)
  
      count = count +1
      print(count, "\n", "current time: ", start)
  
  
      try:
          data, server = client_socket.recvfrom(1024)
          end = time.time()
          elapsed = end - start
          print(f'{data} {pings} {elapsed}')
  
      except socket.timeout:
          print('REQUEST TIMED OUT')
  </code></pre>