开发者

AttributeError: 'socket' object has no attribute 'accpet'

I was building a simple server code and i keep getting this attribute error. I dont understand why. here is my code:

import socket
from socket import*
from time import ctime


HOST = ''
PORT = 21567
BUFSIZ = 1024开发者_如何学Go
ADDR =(HOST, PORT)

tcpsersock = socket(AF_INET, SOCK_STREAM)
tcpsersock.bind(ADDR)
tcpsersock.listen(5)

while True:
    print("waiting for connection...")
    tcpclisock, addr = tcpsersock.accpet()
    print("...Connected from: "),addr

    while True:
        data = tcpclisock.recv(BUFSIZ)
        if not data:
            break
        tcpclisock.send('[%s] %s' %(ctime(), data))

    tcpclisock.close()
tcpsersock.close()


try 'accept' instead of 'accpet'


A simple typo: You want accept instead of accpet (an accidental pet python?).


Tip: Always make sure you don't name your python file as "socket.py" as it is the name of the library.


you have in your code:

tcpclisock, addr = tcpsersock.accpet()

did you mean tcpclisock, addr = tcpsersock.accept() ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜