Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8851187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:05:32+00:00 2026-06-14T13:05:32+00:00

I have noticed while programming a TCP server in Python that there are some

  • 0

I have noticed while programming a TCP server in Python that there are some errors that happen in different conditions when one end or the other stops unexpectedly.

For example, sometimes I got “Pipe broken” (errno.EPIPE) and sometimes “connection aborted” (errno.CONNABORTED or errno.WSAECONNABORTED). There’s also the thing that across OSs the codes are not the same, but I guess Python’s errno module handles that.

I searched a lot for a list of the meanings of the error codes of socket connection, without finding what I was looking for.

What I’ve got until now is something like:

try:
    # write or read operation
except socket.error as e:
    if e.errno in (errno.EPIPE, errno.ECONNABORTED, errno.WSAECONNABORTED):
         print 'Connection lost with server...'

Until now, everything was working smoothly, and even before adding the last one, I had a problem on Windows, and added it, so I’m afraid there might be some cases I did not handle. Also, sometimes, it just didn’t throw an error and kept reading empty lines (with recv), and Bad file descriptor, etc.

Does the SocketServer class provide such a thing? Or TCP connections in general?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T13:05:33+00:00Added an answer on June 14, 2026 at 1:05 pm

    When you try to read from a closed socket in python, no Exception is usually raised. You should just read until recv returns the emty string.

    Writing to a closed socket of course raises an Execption (socket.error) which wraps the error number that the OS raises.

    But you shouldn’t concern yourself too much with error codes. Python isn’t C, or as the tutorial puts it when talking about nonblocking sockets:

    You can check return code and error codes and generally drive yourself crazy. If you don’t believe me, try it sometime. Your app will grow large, buggy and suck CPU. So let’s skip the brain-dead solutions and do it right.

    …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While implementing some security aspects with Spring Security, I have noticed that both Authentication
I've noticed while on my quest to lean functional programming that there are cases
I have noticed while monitoring/attempting to answer common jQuery questions, that there are certain
While debugging a problem in a WPF application, I have noticed that the TwoWay
I have noticed some developers picking up new skills and moving from one platform
While reading some programming books, I notice that the authors says that, in OOP,
After enough playing with asynchronous socket programming I noticed that the server was receiving
I have noticed that the saving of NSUserDefaults takes a while. How can I
While programming under eclipse+PyDev and using Flask framework, I noticed that the auto-organizing imports
I've noticed that there are awvully few programming tutorials in my native language (Latvian).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.