Guest User

Untitled

a guest
Jul 15th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import socket
  3.  
  4. TCP_IP = '127.0.0.1'
  5. TCP_PORT = 6767
  6. BUFFER_SIZE = 1024
  7. MESSAGE = ("A"*4096)+("B"*4096)+("C"*4096);
  8.  
  9. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  10. s.connect((TCP_IP, TCP_PORT))
  11. s.send(MESSAGE)
  12.  
  13. received = "";
  14. while (len(received) < len(MESSAGE)):
  15. data = s.recv(BUFFER_SIZE)
  16. print "received data: %d bytes ending in ...%s" % (len(data), data[-10:])
  17. received += data
  18.  
  19. s.close()
  20.  
  21.  sehe  ~  Projects  stackoverflow  python ./test.py
  22. received data: 1024 bytes ending in ...AAAAAAAAAA
  23. received data: 1024 bytes ending in ...AAAAAAAAAA
  24. received data: 1024 bytes ending in ...AAAAAAAAAA
  25. received data: 1024 bytes ending in ...AAAAAAAAAA
  26. received data: 1024 bytes ending in ...BBBBBBBBBB
  27. received data: 1024 bytes ending in ...BBBBBBBBBB
  28. received data: 1024 bytes ending in ...BBBBBBBBBB
  29. received data: 1024 bytes ending in ...BBBBBBBBBB
  30. received data: 1024 bytes ending in ...CCCCCCCCCC
  31. received data: 1024 bytes ending in ...CCCCCCCCCC
  32. received data: 1024 bytes ending in ...CCCCCCCCCC
  33. received data: 1024 bytes ending in ...CCCCCCCCCC
Add Comment
Please, Sign In to add comment