Jan-10-2022, 02:16 PM
I've managed to figure out both how to clean up the data and strip off the extra characters as well as forward the info to another computer. Now I'm stuck as I'm not sure if I've got the right object to communicate with the other computer. It seems that sockets only transmit in binary and after stripping the information, I am unable to send the re-formatted in text format to the other computer. It will only go in binary with the extra characters and I can also not send a carriage return so that the data sent comes in on a new line with each send? Since I'm unfamiliar with Python and only have experience with older languages, is there a way to do this or do I have to utilize a different language?
I'll include the code where I'm at at this point so you can see what I've done and maybe someone will have a solution.
Thanks in advance!
I'll include the code where I'm at at this point so you can see what I've done and maybe someone will have a solution.
Thanks in advance!
import socket, sys host = '' port = 65432 socksize = 19 s2 = socket.socket() s2.connect(('192.168.1.228',65431)) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((host, port)) s.listen(1) print("Now listening...") def remove_punc(s): from_ = 'GET/&' to = ' ' translation = str.maketrans(from_,to) new = s.translate(translation) return ' '.join(new.split()) while True: conn, addr = s.accept() data = conn.recv(socksize) if not data: x=1 else: s2.send(data) #s2.send(0D0A HEX) data = data.decode('utf-8') print(data) test = (remove_punc(data)) print(test) #s2.send(test)