Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. import socket
  2. import select
  3. import sys
  4.  
  5. sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  6. sock.connect(('localhost', 12345))
  7. while True:
  8. readable, _, _ = select.select([sock, sys.stdin], [], [])
  9. for s in readable:
  10. if s is sock:
  11. print(sock.recv(1024).decode())
  12. elif s is sys.stdin:
  13. sock.send(sys.stdin.readline().encode())
  14. sock.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement