title: socket.error: [Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions
body: <p>I'm trying to create a custom TCP stack using Python 2.6.5 on Windows 7 to serve valid http page requests on port 80 locally.  But, I've run into a snag with what seems like Windows 7 tightened up security.  This code worked on Vista.</p>
  
  <p>Here's my sample code:</p>
  
  <pre><code>import SocketServer
  import struct
  
  class MyTCPHandler(SocketServer.BaseRequestHandler):
      def handle(self):
          headerText = """HTTP/1.0 200 OK
                          Date: Fri, 31 Dec 1999 23:59:59 GMT
                          Content-Type: text/html
                          Content-Length: 1354"""
          bodyText = "&lt;html&gt;&lt;body&gt;some page&lt;/body&gt;&lt;/html&gt;"
          self.request.send(headerText + "\n" + bodyText)
  
  if __name__ == "__main__":
      HOST, PORT = "localhost", 80
      server = SocketServer.TCPServer((HOST, PORT), MyTCPHandler)
      server.serve_forever()
  </code></pre>
  
  <blockquote>
    <p><b>C:\python>python TestServer.py</b>
    Traceback (most recent call last):<br>
    File "TestServer.py", line 19, in
    
        server = SocketServer.TCPServer((HOST, PORT),
    MyTCPHandler)   File
    "C:\Python26\lib\SocketServer.py",
    line 400, in <strong>init</strong>
        self.server_bind()   File "C:\Python26\lib\SocketServer.py",
    line 411, in server_bind
        self.socket.bind(self.server_address) 
    File "", line 1, in bind</p>
    
    <p>socket.error: [Errno 10013] An attempt
    was made to access a socket in a way
    forbidden by its access permissions</p>
  </blockquote>
  
  <p>How exactly do I get this to work on Windows 7?</p>
  
  <p>[Edit on 5/5/2010 @ 2344 PDT]  This <a href="https://stackoverflow.com/questions/550032/what-causes-python-socket-error">answer</a> explains that the error is caused by the need for elevated / superuser privileges when accessing ports lower than 1024.  I'm going to try using a higher port number to see if that works.  However, I still would like to know why my local admin account can't access port 80.  </p>