Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- client_socket.connect(("127.0.0.1", 8081))
- print("connected")
- #added in section 1.8
- #receives data
- data = client_socket.recv(1024) #1024 is max bytes to read at a time
- message = data.decode()
- print(message)
- #challenge at the end of 1.8
- #send a response message
- response = "Nice to connect with you"
- data = response.encode()
- client_socket.send(data)
- #close sockets
- client_socket.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement