init
This commit is contained in:
21
python/sockets/client.py
Normal file
21
python/sockets/client.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import socket
|
||||
|
||||
# Create a socket object
|
||||
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
# Define the host and port to connect to
|
||||
host = '10.100.54.10'
|
||||
port = 8000
|
||||
|
||||
# Connect to the server
|
||||
client_socket.connect((host, port))
|
||||
|
||||
# Send data to the server
|
||||
client_socket.sendall("Hello from the client!".encode())
|
||||
|
||||
# Receive a response from the server
|
||||
response = client_socket.recv(1024)
|
||||
print("Response from server:", response.decode())
|
||||
|
||||
# Close the connection
|
||||
client_socket.close()
|
||||
Reference in New Issue
Block a user