Is there any method for Socket of Python to deliver XML instead of bytes. As the server side only recieves raw XML. I tried the code below but it raises attribute error, it asks for bytes instead of string. Any idea?
import socket
server_ip = "192.168.88.52"
port = 2605
socket_obj = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket_obj.settimeout(5.0)
try:
socket_obj.connect((server_ip, port, ))
command = '<SERVICE ID="TA"><TRACKID_GET></TRACKID_GET></SERVICE>'
socket_obj.send(command)
print(f"Successfully send the command")
data = socket_obj.recv(4096)
print(f"Received Response: {data}")
except socket.timeout as e:
print(f"Response TimeOut: {e}")
socket_obj.close()
except Exception as e:
print(f"Failed to connect to the P1 server: {e}")