Python UDP communication using Socket, check data received
<p>I'm pretty new to the Python, trying to write a code to receive string from UDP connection, the problem I have now is that I need to receive data from 2 sources, I want the program continue looping if there is no data from either or both of them, but now if there is no data from source 2, it will stop there and wait for the data, how to solve it?
I was thinking about using if statement, but I don't know how to check if the incoming data is empty of not, any ideas will be appreciated!</p>

<pre><code>import socket

UDP_IP1 = socket.gethostname()
UDP_PORT1 = 48901
UDP_IP2 = socket.gethostname()
UDP_PORT2 = 48902

sock1 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock1.bind((UDP_IP1, UDP_PORT1))
sock2 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock2.bind((UDP_IP2, UDP_PORT2))

while True:
    if sock1.recv != None:
        data1, addr = sock1.recvfrom(1024)
        data1_int = int(data1)
        print "SensorTag[1] RSSI:", data1_int

    if sock2.recv != None:
        data2, addr = sock2.recvfrom(1024)
        data2_int = int(data2)
        print "SensorTag[2] RSSI:", data2_int
</code></pre>