Advertisement
Tlams

py_getstatus

Sep 13th, 2013
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. import socket
  2. from struct import *
  3.  
  4. UDP_IP_local = "192.168.0.X" #IP carte local
  5. UDP_PORT_local = 29070 #SOCK local
  6.  
  7. UDP_IP_dest = "xx.xx.xx.xx" #IP server // pour get le master: - Choper l'ip master
  8. UDP_PORT_dest = 29060  #Port server  // master : 29060
  9.  
  10. sock = socket.socket(socket.AF_INET, # Internet
  11.                      socket.SOCK_DGRAM) # UDP
  12.  
  13. sock.bind((UDP_IP_local, UDP_PORT_local)) # ouverture socket local
  14.  
  15. sock.connect((UDP_IP_dest, UDP_PORT_dest)) #Connexion au distant
  16.  
  17. sock.send("\xFF\xFF\xFF\xFF getstatus") # commande
  18.  
  19. sock.settimeout(5) #timeout pour sortir proprement
  20.  
  21. while True:
  22.     try:
  23.         data, addr = sock.recvfrom(4096) # buffer size is 1024 bytes
  24.         print data
  25.     except:
  26.         print "TimeOut!"
  27.         break
  28.  
  29. sock.close()
  30. print "Fin"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement