import webapp2
from socket import *
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.write('Hello world!')
serverport = 12001
serversocket=socket(AF_INET,SOCK_STREAM)
serversocket.bind(('',serverport))
serversocket.listen(5)
while 1:
connectionsocket , addr = serversocket.accept()
sentence = connectionsocket.recv(1024)
capsen = sentence.upper()
connectionsocket.send(capsen)
connectionsocket.close()
app = webapp2.WSGIApplication([
('/', MainHandler)
], debug=True)
我使用上面的代码从客户端接收句子,然后用大写的句子回复。(使用app引擎)。但我在serversocket.bind()行获得了权限被拒绝错误。 我尝试更改端口号,但它给出了相同的错误。