Advertisement
johnpentyrch

server1

Jun 7th, 2020
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. import socket
  2. server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  3. server_socket.bind(("0.0.0.0",8081))
  4. server_socket.listen()
  5. print("waiting for connection")
  6. connection_socket, address = server_socket.accept()
  7. print("Client connected")
  8. message="hello. thanks for connecting"
  9. data=message.encode()
  10. connection_socket.send(data)
  11. #now get message from client
  12. data=connection_socket.recv(1024)
  13. message=data.decode()
  14. print(message)
  15. connection_socket.close()
  16. server_socket.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement