'Sending a text file via tcp python

I need help with my TCP client. I have a text file that I want to send to my server, however I want each line to be sent to the server one by one with a 1-second interval. Unfortunately, I have no idea how this works, since I don't have that much programming experience yet.

This is the code I have right now.

import socket
import sys
import pickle

HEADER = 64
PORT = "PORTHERE"
FORMAT = 'utf-8'
DISCONNECT_MESSAGE = "!DISCONNECT"
SERVER = "IPHERE"
ADDR = (SERVER, PORT)
COORDX = 0
COORDY = 0

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(ADDR)

def send(msg):
    message = msg.encode(FORMAT)
    msg_length = len(message)
    send_length = str(msg_length).encode(FORMAT)
    send_length += b' ' * (HEADER - len(send_length))
    client.send(send_length)
    client.send(message)
    print(client.recv(2048).decode(FORMAT))

while 0 == 0:
    message = ("'  CBuser;login;1;48bcaWE4836916d4e")
    if message == ("disconnect"):
        send(DISCONNECT_MESSAGE)
        sys.exit()
    else:
        send(message)




Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source