Connectionabortederror: [Winerror 10053] The software in your console aborted an established connection

Source: Internet
Author: User

The socket server throws an exception when receiving the socket client

Connectionabortederror: [Winerror 10053] The software in your console aborted an established connection.

Socket service-side code

#-*-coding:utf-8-*-#Author:jiang Zu XingImportSocket,timesocketserver=Socket.socket () host="0.0.0.0"Port=9999Socketserver.bind ((host,port)) Socketserver.listen (5) whiletrue:client,addr=socketserver.accept ()Print("connections from:", addr) msg="Show server return data"     whileTrue:Print("ready to receive data") Data= CLIENT.RECV (1024)        Print("Receive data complete")        ifdata = =0:Print("No Data")             Break        Else:            Print(Data.decode ('Utf-8')) Client.send (Msg.encode ()) Client.close () socketserver.close ()

Socket client Code

#-*-coding:utf-8-*-#Author:jiang Zu XingImportsocket,timesocket_client=Socket.socket () host="192.168.1.35"Port=9999Data="222"Socket_client.connect ((host,port))Print("Start Sending") Socket_client.send (Data.encode ())Print("start receiving") msg=SOCKET_CLIENT.RECV (1024)Print("Receive End")Print(Msg.decode ('Utf-8')) Time.sleep (100)

Abnormal

Traceback (most recent):  File "c:/users/administrator/desktop/jiang/python/demo/Network programming/socket_server.py ", line, <module>    data = CLIENT.RECV (1024x768) Connectionabortederror: [Winerror 10053] The software in your console aborted an established connection.

A problem occurred:

Just learned the socket writing the hands and feet of this

When server-side receive data is turned off, the client is forced to close the connection and the above error message appears.

Suggestions:

Exit the dead loop after receiving the data, do not let the recv () function block, before shutting down the client (file sender), it is recommended to send a message to the server side (file receiver) "I want to disconnect", and then both sides closed the connection close

Connectionabortederror: [Winerror 10053] The software in your console aborted an established connection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.