move dirs
This commit is contained in:
22
code/Python/unixsockets/client.py
Normal file
22
code/Python/unixsockets/client.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import socket
|
||||
import os
|
||||
|
||||
# Set the path for the Unix socket
|
||||
socket_path = '/tmp/myapp.sock'
|
||||
|
||||
# Create the Unix socket client
|
||||
client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
|
||||
# Connect to the server
|
||||
client.connect(socket_path)
|
||||
|
||||
# Send a message to the server
|
||||
message = 'Hello from the client!'
|
||||
client.sendall(message.encode())
|
||||
|
||||
# Receive a response from the server
|
||||
response = client.recv(1024)
|
||||
print(f'Received response: {response.decode()}')
|
||||
|
||||
# Close the connection
|
||||
client.close()
|
||||
Reference in New Issue
Block a user