Socket的测试(客户反馈连接失败不报错)


问题是:使用connect命令,成功和失败都不显示

>>> import usocket

>>> client = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)  ////每次连接连接前必须定义

>>> sockaddr = usocket.getaddrinfo('www.tongxinmao.com',80)[0][-1]    ////正确端口,socket

>>> client.connect(sockaddr)

>>> client.close()              ////////////// 每次连接后想重新连接必须关闭

>>> client = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)    ////每次连接连接前必须定义

>>> sockaddr = usocket.getaddrinfo('www.tongxinmao.com',82)[0][-1]       ////错误端口,socket

>>> client.connect(sockaddr)

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

OSError: 104

>>> client.close()                 //////////////每次连接后想重新连接必须关闭

>>> client = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)   ////每次连接连接前必须定义

>>> sockaddr = usocket.getaddrinfo('www.tongxinmao.com',80)[0][-1]        ////正确端口,socket

 

>>> client.connect(sockaddr)

>>> client.close()                 //////////////每次连接后想重新连接必须关闭