Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- server_socket.bind(("0.0.0.0",8081))
- server_socket.listen()
- print("waiting for connection")
- connection_socket, address = server_socket.accept()
- print("Client connected")
- message="hello. thanks for connecting"
- data=message.encode()
- connection_socket.send(data)
- #now get message from client
- data=connection_socket.recv(1024)
- message=data.decode()
- print(message)
- connection_socket.close()
- server_socket.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement