Can't see why this error is happening

I’m trying to get some code to work that I found on how to transfer files in a LAN environment. The code is as follows:

#*		Server Code

import socket
import tqdm
import os

# device's IP address

# create the server socket
# TCP socket
s = socket.socket()

# bind the socket to our local address

# enabling our server to accept connections
print(f"[*] Listening as {SERVER_HOST}:{SERVER_PORT}")

# accept connection if there is any
client_socket, address = s.accept()

# if below code is executed, that means the sender is connected
print(f"[+] {address} is connected.")

# receive the file infos
# receive using client socket, not server socket
received = client_socket.recv(BUFFER_SIZE).decode()
filename, filesize = received.split(SEPARATOR)

# remove absolute path if there is
filename = os.path.basename(filename)

# convert to integer
filesize = int(filesize)

# now, receive the file
progress = tqdm.tqdm(range(filesize), f"Receiving {filename}", unit="B", unit_scale=True, unit_divisor=1024)
with open(filename, "wb") as f:
	while True:
		#read 1024 bytes from the socket (receive)
		bytes_read = client_socket.recv(BUFFER_SIZE)
		if not bytes_read:
			# nothing is received
			# file transmitting is done
		#write to the file the bytes we just received
		# update the progress bar
	# close the client socket
	# close the server socket

But I get this error:

File “C:\python311\Server” , line 28, in
client_socket, address = s.accept()

File “C:\python311\lib\”, line 294, in accept
fd, addr = self._accept()

oserror: [winerror10022] An invalid argument was supplied

Any help would be appreciated.

I removed the import of tqdm and then used the first 45 lines only.
The rest is after the error you saw.

I ran that code and it works on Windows 10 and Linux.

On windows I did get a “Windows Defender” dialog that asked me to allow the program to use the network. Did you get that dialog? Did you answer allow?

I tested using curl http://<ip-address>:5001

Thanks, Barry. I was using my laptop for the server code and it showed the error. When I saw your comment that it worked in your system, I tried it in my desktop system and it worked also. Now I just need to figure out what files need to be changed in my laptop.
Thanks again.