简体   繁体   中英

AttributeError: '_socketobject' object has no attribute 'bind'

here is my code:

import sae
import socket, sys
host = ''
port = 5005
def app(environ, start_response):
    status = '200 OK'
    response_headers = [('Content-type', 'text/plain')]
    start_response(status, response_headers)
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind((host, port))
    s.listen(2)
    while 1:
        client, addr = s.accept();
        print("Got connection from ", addr);
        while 1:
            print("the word you want to send:")
            buf = sys.stdin.readline().strip()
            if not buf:
                break
            client.send(bytes(buf, 'UTF-8'))
            data = client.recv(1024);
            if data:
                print(data)
    return ['Hello, world!']

application = sae.create_wsgi_app(app)

but I am getting an Attribute Error that says:

Traceback (most recent call last):
  File "/usr/local/sae/python/lib/python2.7/site-packages/sae/__init__.py", line 18, in
   new_app
    return app(environ, start_response)
  File "/data1/www/htdocs/850/love2note/1/index.wsgi", line 11, in app
    s.bind((host, port))
AttributeError: '_socketobject' object has no attribute 'bind'

I really do not understand what I need to do to solve this issue. If anyone can please help me, I'll be really grateful.

import sae you mean Sina App Engine ?

if True: bind is not allowed by SAE. API

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM