I'm trying to translate an functional UDP socket I have to TCP, but I'm having a hard time because I can't find the explanation why I can't get inputs to work on the TCP. The same code, in UDP, would work. In TCP I simply get a 'blank' input.
Client Side
elif cmd[0] == 'INSERT':
name = input("\nNAME: ")
artist = input("ARTIST: ")
album = input("ALBUM NAME: ")
year = input("YEAR: ")
newsong = name + ";" + artist + ";" + album + ";" + year + "\n"
sock.sendto(bytes(newsong, "UTF-8"), serv)
Server Side
elif cmd[0].upper() == 'INSERT':
with open("songs.txt", "a", encoding='UTF-8') as fd:
receive_message = con.recvfrom(TAM_MSG)
msg = receive_message[0]
fd.write(str(msg, "UTF-8"))
fd.close()
That totally works in UDP, but not in TCP. Is there any way I can input to the TCP server? How? Thank you.