Here are three network-related exceptions. These
were caught by "except" with no exception type, because
none of the more specific exceptions matched. This
is what a traceback produced:
1. File "D:\Python24\li b\socket.py", line 295, in read
data = self._sock.recv (recv_size)
timeout: timed out
2. File "D:\Python24\li b\socket.py", line 295, in read
data = self._sock.recv (recv_size)
error: (10054, 'Connection reset by peer')
3. File "D:\Python24\li b\socket.py", line 317, in readline
data = recv(1)
IOError: [Errno socket error] timed out
For 1 and 2, those are errors that aren't in the
exception hierarchy. Looking at the C code for "socketmodule.c ",
it's clear that "socket.err or" doesn't inherit from any standard
exception class. See, in "init_socket()" :
socket_error = PyErr_NewExcept ion("socket.err or", NULL, NULL);
That first NULL should be some parent exception, maybe "IOError".
As it is, "socket.err or" is outside the standard exception hierarchy.
That's not too good.
Case #3, IOError, should have been caught by this:
except IOError, message: # I/O error
But it wasn't. The "IOError" fell through, was caught by the
next outer exception block, and was logged as a generic
error.
I can't find where in the Python socket module an "IOError"
could be raised. I would have expected "socket.timeout ".
Anyway, I need to know the full set of exceptions that can
be raised by sockets. Thanks.
John Nagle
Apr 23 '07
10 3586
On a related note, M2Crypto's exceptions are direct children
of Exception. If we add NetworkError, there will be a better
place to put them.
Currently, you have to catch, at least,
M2Crypto.SSL.Ch ecker.SSLVerifi cationError
M2Crypto.SSL.SS LError
both of which can be raised by socket operations if
M2Crypto is installed. I'm not sure what errors the
stock SSL module raises.
(I'm running stress tests on a dedicated machine in a colocation
facility. It's examining 11,000 known spam and malware sites right
now. This exercises the error handling, forcing many unusual cases
and logging the problems. That's why I'm discovering all these library
issues.)
John Nagle
Steve Holden wrote:
John Nagle wrote:
>Steve Holden wrote:
>>John Nagle wrote:
Steve Holden wrote:
John Nagle wrote: [socket.error bug report]
>>All these notes should be included in the bug report, as I suspect the module would benefit from additional clarity.
Done. See
[ 1706815 ] socket.error exceptions not subclass of StandardError
Also see
[ 805194 ] Inappropriate error received using socket timeout [ 1019808 ] wrong socket error returned [ 1571878 ] Improvements to socket module exceptions [ 708927 ] socket timeouts produce wrong errors in win32
for related but not identical problems in that area.
Thanks. At least this is less likely to be overlooked now.
regards
Steve
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: cody |
last post by:
I have a method that gets called if the user presses a certain button.
If the object is in a state that doesn't allow the calling of that method,
what should I do? Should I better throw an InvalidOperationException or
should I derive my own exceptions from ApplicationException?
In general, it is not clear to me when to use the predefined exceptions and
when to create new ones by deriving from ApplicationException.
And a last question:...
|
by: faktujaa |
last post by:
Hi,
I am having some problem with callback used in socket implementation.
private static void Connect(string strPrtrIPAddr, int intPrtrPort, ref
Socket rsocClient)
{
try
{
// Create remote end point.
System.Net.IPAddress IPAddress = System.Net.IPAddress.Parse(strPrtrIPAddr);
System.Net.IPEndPoint IPEndPoint = new System.Net.IPEndPoint(IPAddress,
|
by: mag31 |
last post by:
Is there any way to find out if a particular .net function will throw an
exception without first generating the exception?
I am using structured exception handling i.e. try catch finally blocks with
a top level catch all for Exception. However, I would like to be able to
catch most .net exceptions when they are generated. I would then be able to
generate a valuable exception message and do something about it!!! Hence the
question above....
|
by: Noah Roberts |
last post by:
I am a bit confused about how inheritance works with regard to
exceptions apparently.
class ParentEx : public std::exception
{
};
class SubEx : public ParentEx,std::runtime_error
{
};
|
by: Turamnvia Suouriviaskimatta |
last post by:
I 'm following various posting in "comp.lang.ada, comp.lang.c++ ,
comp.realtime, comp.software-eng" groups regarding selection of a
programming language of C, C++ or Ada for safety critical real-time
applications. The majority of expert/people recommend Ada for safety
critical real-time applications. I've many years of experience in C/C++ (and
Delphi) but no Ada knowledge.
May I ask if it is too difficult to move from C/C++ to Ada?...
| |
by: Einar Høst |
last post by:
Hi,
I'm getting into the Trace-functionality in .NET, using it to provide some
much-needed logging across dlls in the project we're working on. However,
being a newbie, I'm wondering if some more experienced loggers can provide
me with some ideas as to how to log in a simple yet flexible manner. For
instance, I'd like the code to be as uncluttered as possible by Trace
statements.
As an example of basic logging functionality, I've come...
|
by: dcassar |
last post by:
I have had a lively discussion with some coworkers and decided to get
some general feedback on an issue that I could find very little
guidance on. Why is it considered bad practice to define a public
member with a return type that is derived from System.Exception? I
understand the importance of having clean, concise code that follows
widely-accepted patterns and practices, but in this case, I find it
hard to blindly follow a standard...
|
by: ThunderMusic |
last post by:
Hi,
I'm currently working with sockets. I accept connections using
m_mySocket.Listen(BackLogCount); But when I want to stop listening, I
shutdown all my clients and call m_mySocket.Close(), but it always raise a
OnConnect event (actually, it calls the callback function as if there was a
new connection attempt) and I receive a ObjectDisposedException as soon as I
do m_mySocket.EndAccept.
Does anyone have any idea of what I could do about...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |