def serverUDP(host, port): x=0 old = bytearray() sock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM) # UDP, socket.SOCK_RAW, socket.IPPROTO_UDP) sock.bind( (host,port) ) print "p" #sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) while 1: data, addr = sock.recvfrom(2048) # buffer size is 1024 bytes buff = map(ord,data) #print buff ifd = len(buff) print ifd if(len(buff)>1300 and len(buff)<1400): buf = buff#[28:1353]#[51:] #print buf #exit(0) if x==0: old = buf result = messaggi.deserializzaStatoLineaIXL(buf) print "qui",result else: risp = scarta2(old, buf) if(not risp): result = messaggi.deserializzaStatoLineaIXL(buf) print result old = buf x+=1
except socket.error as msg: p=0 #sock.close() #print "nessun messaggio ricevuto" data, addr = sockx.recvfrom(2048) # buffer size is 1024 bytes buff = map(ord,data) #print buff ifd = len(buff) #print ifd if(len(buff)>1300 and len(buff)<1400): buf = buff#[28:1353]#[51:] #print buf #exit(0) if x==0: old = buf result = messaggi.deserializzaStatoLineaIXL(buf) print "qui",result else: risp = scarta2(old, buf) if(not risp): result = messaggi.deserializzaStatoLineaIXL(buf) print result old = buf x+=1 #print lista buffi = messaggi.messageRBC1(lista) sendUDP(buffi,4010) # time.sleep(2)