Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. import socket
  2.  
  3. # DZIAŁA OK - PUBLIC -> PUBLIC
  4. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  5. s.bind(('192.168.200.15', 7777))
  6. s.sendto('test'.encode(),('192.168.200.16', 10000))
  7.  
  8. # DZIAŁA OK - LOOPBACK -> LOOPBACK
  9. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  10. s.bind(('127.0.0.1', 7777))
  11. s.sendto('test'.encode(),('127.0.0.1', 10000))
  12.  
  13. # DZIAŁA OK - PUBLIC -> LOOPBACK
  14. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  15. s.bind(('192.168.200.15', 7777))
  16. s.sendto('test'.encode(),('127.0.0.1', 10000))
  17.  
  18. # BŁĄD - LOOPBACK -> PUBLIC
  19. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  20. s.bind(('127.0.0.1', 7777))
  21. s.sendto('test'.encode(),('192.168.200.16', 10000))
  22. # WYNIK:
  23. # Traceback (most recent call last):
  24. # File "x.py", line 21, in <module>
  25. # s.sendto('test'.encode(),('192.168.200.16', 10000))
  26. #OSError: [Errno 22] Invalid argument
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement