how to send larger files over socket python code example

Example: python socket send big data

# Client Side Program (Sender)
import socket

data = b"hsfbhdhfbjsnkdfkkn" * 1000  # Very Big Data to send

server = ('127.0.0.1', 8000)

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(server)

block_size = 1000
block_number = 0
block_data = b''

while True:
  # Selected block to send
  block_data = data[block_number * block_size: (block_number + 1) * block_size]
  
  s.send_all(block_data)
  
  if not block_data:
    break
  
  block_number += 1
s.close()