Search code examples
pythongoogle-app-enginesocketswebapp2

Unable to use the socket library in webapp2


For some reason I'm unable to use the socket library completely in webapp2. On printing the dir contents of the library, I get the following:

[
 'AF_INET', 'SOCK_DGRAM', 'SOCK_STREAM', '_GLOBAL_DEFAULT_TIMEOUT',
 '__all__', '__builtins__', '__doc__', '__file__', '__loader__', '__name__',
 '__package__', '_fileobject', 'error', 'gaierror', 'getdefaulttimeout',
 'herror', 'setdefaulttimeout', 'ssl', 'timeout'
]

As you can see, this is not the complete socket library(it also lacks the socket() constructor). Why is this happening and how can I fix it?


Solution

  • Because opening a socket is explicitly forbidden in AppEngine.