title: How to check the python socket recvfrom() data
body: <p>I am working on socket programming in python. Using ESP python i have created a socket to server and sending a request (in API packet format, according to server code it will respond). In receiving socket, i need to check the data(if data is received, it need continue to next operation. If not, i need to send request once again). 
  sending is okay. In receiving socket, if it is not receiving data, it is not going to next instruction.. please help me out.</p>
  
  <p>code:</p>
  
  <pre><code>try:
  
      s = socket(AF_INET, SOCK_DGRAM)
      print "socket created"
  
  except socket.error:
  
      print "failed to create socket"
      sys.exit()
  </code></pre>
  
  <p>sending data: </p>
  
  <pre><code>s.sendto("packet of data", 0, (HOST,PORT))
  </code></pre>
  
  <p>In receiving:</p>
  
  <pre><code>recvpack, payload=s.recvfrom(1024)
  
  if not recvpack:
  
      s.sendto("packet of data", 0, (HOST,PORT))
  
  elif(recvpack[]="packet of data"):
  
      pass # continue to next operations..
  </code></pre>
  
  <p>In the above receiving statement, if <code>recvfrom()</code> in not getting anydata, how to check <code>recvpack</code> and get back to next operations.. If <code>socket.settimeout()</code> or <code>socket.setblocking()</code> is the solution, how to use these..</p>