universal communication Python module

My Universal python module for communication between process, between nodes, between computers, between robots

#makin 2019
import socket
from threading import Thread

def receive(port=8881,verbose=False):
    server_socket=socket.socket() 
    server_socket.bind(('',port))
    server_socket.listen(1)
    if verbose:print('waiting for a connection...')
    client_connection,client_address=server_socket.accept()
    if verbose:print('connected to ',client_address[0])
    ultimate_buffer=b''
    while True:
        receiving_buffer = client_connection.recv(1024)
        if not receiving_buffer: break
        ultimate_buffer+= receiving_buffer
    client_connection.close()
    server_socket.close()
    if verbose:print ('frame received')
    return ultimate_buffer

def send(bytearraydata, server_address='127.0.0.1',port=8881,verbose=False):
    client_socket=socket.socket()
    try:
        client_socket.connect((server_address, port))
        if verbose:print ('Connected to %s on port %s' % (server_address, port))
    except socket.error as e:
        if verbose:print ('Connection to %s on port %s failed: %s' % (server_address, port, e))
        return
    client_socket.sendall(bytearraydata)
    client_socket.shutdown(1)
    client_socket.close()
    if verbose:print ('data sent')

"""
asynchronously listening numpy ndarray and store data to current_data
using threading.Thread, which means runs in the same interpreter & process as the instantiator. instance.current_data can be accessed from the instantiator
"""
class AsyncReceiver(Thread):
    def __init__(self,parent=None, port=8881, verbose=False):
        super().__init__(parent)
        self.verbose = verbose
        self.port = port
        self.daemon = True
        self.current_data = None #the data received can be read here
        self.countstamp = 0 #countstamp increased (+= 1) for each changes in current_data
        self.start()
    
    def run(self):
        while True:
            t = receive(self.port,verbose=self.verbose)
            self.current_data = t
            self.countstamp += 1
            print(f'received #{self.countstamp} {t}')



if __name__=="__main__":
    import unittest
    import time
    class TestSendReceive(unittest.TestCase):
        def test_send(self):
            receiver = AsyncReceiver(port=9000)
            time.sleep(1)
            data = b"makin"
            send(data,port=9000)
            time.sleep(1)
            self.assertEqual(receiver.current_data,b"makin")
        
    unittest.main()