Building a socket client

For simplicity, our client will be a socket that connects to our server that was developed with Twisted.

You can find the following code in the socket_client.py file:

#!/usr/bin/env python3
from socket import socket

s = socket()
s.connect(("127.0.0.1", 8080))
while True:
output_data = input("Enter message> ")
if output_data:
s.send(output_data.encode())
input_data = s.recv(1024)
if input_data:
print(input_data.decode("utf-8"))

In this section, we have analyzed how to create our own socket client for communicating with the Twisted server on port 8080.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset