Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import socket,time
  2.  
  3. eki = socket.socket()
  4. eki.bind(('', 54321))
  5. eki.listen(1)
  6.  
  7. while True:
  8.  
  9. conn, addr = eki.accept()
  10. print( 'robot connected:', addr )
  11. i = 1
  12. data, addr = conn.recvfrom(1024)
  13. print( "Got: " + str(data) )
  14.  
  15. while True:
  16. try:
  17. s = "<Atos><A>TRUE</A><B>FALSE</B><C>TRUE</C></Atos>"
  18. s = '<Atos><Task Active="1" Code="%i"/></Atos>' % i
  19. conn.send(bytes(s, encoding='ascii'))
  20. print( "Sent: %s" % s )
  21. time.sleep(3)
  22. i = i + 1
  23. except Exception as e:
  24. print( e )
  25. raise e
  26. break
  27. conn.close()
  28.  
  29. atos.close()
  30. eki.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement