0
votes

i was writing a small IRC bot when much to my dismay, i got an error that i cannot seem to understand or fix. the code i used worked before but now windows seems to not be happy with it.

Error:

socket.error: [Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions

This is the quick code i knocked up:

import socket

s = socket.socket().connect(("irc.cryto.net", 6667))
s.send("NICK kNij\r\n")
s.send("USER kNij 0 0 kNij :derp :3\r\n")
inputfile = s.makefile()
while 1:
    line = inputfile.readline()
    print line

Edit: it seems to be an all over problem with some sockets

2

2 Answers

1
votes

That can never work. connect returns None (at least on Windows 7 with Python 2.7.2).

Try:

import socket

s = socket.socket()
s.connect(("Lidingo.SE.EU.Undernet.org", 6667))
s.send("NICK kNij\r\n")
s.send("USER kNij 0 0 kNij :derp :3\r\n")
inputfile = s.makefile()
while 1:
    line = inputfile.readline()
    print line,

(I changed the server to make sure the code really works)

Now, why you get that error, and not, like me:

Traceback (most recent call last):
  File "D:\workspaces\generic\SO_Python\9337618.py", line 4, in <module>
    s.send("NICK kNij\r\n")
AttributeError: 'NoneType' object has no attribute 'send'

is a mistery...

0
votes

maybe the port 8000 is not accessible. try change the port number to 8888 by using python manage.py runserver 8888 command. it worked for me