Reputation: 154
I created a simple socket program by python by creating two different files Server.py and a Client.py and tried to connect it by s.connect((host,port))
but
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions
occurs
I have looked up many solutions on the net regarding this issue which could be due to Firewall issues, Malware in system, outbound firewall settings , Run by Administrator, even checked if the port was not in use by netstat in cmd but none of them solved my issue.
plz help
This is my code:
#SERVER.py
import socket
s= socket.socket()
host= socket.gethostname()
port = 5000
s.bind((host,port))
s.listen(1)
print(host)
print('Waiting for any incoming connections...')
conn, addr = s.accept()
print(addr,'Has connected to the server')
#CLIENT.py
import socket
s = socket.socket()
host=input('Enter host address:')
port=5000
s.connect((host,port))
print('Connected...')
Upvotes: 2
Views: 5759
Reputation: 34
Try localhost, if host is not working. Like for eg. host='127.0.0.1' #( The server's hostname or IP address)and use a port >1023 (As those are non-privileged ports) If its still not working, you can try changing your network and try the same steps. If any further issue occurs regarding the same error there must be a issue with your system, for that try factory reset. Then it will work 100% Best of luck.
Upvotes: 1