'Error while trying to use the vidstream libary

I've been trying to use the vidstream libary to Share the screen of clients to the server, but I've been running into issues when trying to stop screen sharing, and then start it a again a few seconds later.

Server:
#When button 1 is pressed:
def ask_for_stream(self, name):
    stream_server.start_server()
    connection.send("2".encode())

When button 2 is pressed:
def stop_stream():
    connection.send("3".encode())
    stream_server.stop_server()

Client:
    def receive():
    while True:
        server_message = self.client.recv(1024).decode('utf-8')
        if server_message[0] == '2':
            self.stream_client.start_stream()
        elif server_message[0] == '3':
            try:
                self.stream_client.stop_stream()
            except Exception as e:
                print(e)

In a single use, Button1 and Button2 both work perfectly. I'm getting the Error when I press Button1, Button2, and then Button1 again (when I want to screenshare, stop the screensharing for a few seconds, and then share the screen again). The error I'm getting is: OSError: [WinError 10056] A connect request was made on an already connected socket. I couldn't find a way so solve it. Thanks in advance!

*Note: In addition the socket created using vidstream, I have another Client-Server socket connection (that lets me send the messages "2", "3" etc..)



Sources

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

Source: Stack Overflow

Solution Source