I started a socket tcp server and two socket clients
def loopRedis(self):
socket = self.request
while True:
for key in r.scan_iter(match='push:*', count=100000):
# print key
##find the msg that I need to push
data = json.loads(r.get(key))
##get the userid from push:*
flag = False
for userKey in r.scan_iter(match='redis:*', count=100000):
if flag == False:
if r.hget(userKey,'userid') == data['userid']:
print '======='
print r.hget(userKey,'ip')
print int(r.hget(userKey,'id'))
print '|||||||||'
#find the map(ip and id and userid)from redis:*
socket.sendto(prpcrypt().encrypt(r.get(key)), (r.hget(userKey,'ip'),int(r.hget(userKey,'id'))))
flag = True
# r.delete(key) ##delete when I send
time.sleep(2) ## looping
I recoded every clients when they connected to the socket
then socket tcp server use socket.sendto(string[,flag],address) method.
but why the both of clients received the data. I just want send to someone.
So how can I do this? thank you.
socket = self.requestline. - FujiApple