SHARE
TWEET

Untitled

a guest Oct 17th, 2019 138 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import socket
  4.  
  5. HOST = 'localhost'  # Стандартный адрес петлевого(loopback) интерфейса (localhost)
  6. PORT = 65432  # Порт для прослушивания (непривилегированные порты > 1023)
  7. with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
  8.     s.bind((HOST, PORT))
  9.     s.listen(1)
  10.     conn, addr = s.accept()
  11.     with conn:
  12.         print('Connected by', addr)
  13.         while True:
  14.             data = conn.recv(1024)
  15.             if not data:
  16.                 break
  17.             conn.send(data[::-1])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top