init
This commit is contained in:
16
python/tcp_sockets/client.py
Normal file
16
python/tcp_sockets/client.py
Normal file
@ -0,0 +1,16 @@
|
||||
import socket
|
||||
|
||||
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
server_address = input("address to connect to: ")
|
||||
server_port = input("port to connect through: ")
|
||||
|
||||
client_socket.connect((server_address, int(server_port)))
|
||||
|
||||
while 1:
|
||||
transmission = input("text to send: ")
|
||||
client_socket.send(transmission.encode('utf-8'))
|
||||
response = client_socket.recv(8192).decode('utf-8')
|
||||
print("server replied: " + response)
|
||||
|
||||
client_socket.close()
|
||||
Reference in New Issue
Block a user