EDIT - inconsistent use of names in last post:
import socket
import time
?
# The address and port of the local IBC command server
TCP_IP = '127.0.0.1' #localhost
TCP_PORT = {tbc as in config.ini}
?
# The message to send to the IBC command server to request a restart
RESTART_COMMAND = 'RESTART\n'
?
# The buffer size for receiving data from the IBC command server
BUFFER_SIZE = 1024
?
# Connect to the IBC command server and send the restart command
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
? ? sock.connect((TCP_IP, TCP_PORT))
? ? sock.sendall(RESTART_COMMAND.encode())
?
? ? # Receive and discard any data from the IBC command server
? ? data = sock.recv(BUFFER_SIZE)
? ? print(f"received data: {data}")
? ? time.sleep(1)
? ? print("closing socket")
?
print("exiting script")