3. Servidor codigo

import socket
import sys

# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Bind the socket to the port
server_address = ('localhost', 10000)
print('starting up on {} port {}'.format(*server_address))
sock.bind(server_address)

# Listen for incoming connections
sock.listen(1)

while True:
    # Wait for a connection
    print('waiting for a connection')
    connection, client_address = sock.accept()
    try:
        print('connection from', client_address)

        # Receive the data in small chunks and retransmit it
        while True:
            data = connection.recv(300) #para el caso de enviar cifrado, al enviar el dato ocupa muchos mas bytes, tener en cuenta
            print('received {!r}'.format(data))
            if not data:
                print('no data from', client_address)
                break

    finally:
        # Clean up the connection
        connection.close()