473,224 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

A blocking operation was interrupted by a call to WSACancelBlockingCall -- can async I/O solve this problem? roburst network programming

Hi,

I have a 100 clients/ one server application, use ugly one thread pre client
approach. And both side user sync I/O.

I frequently see the error on server side(client side code is same, but I
don't see the error):

"System.IO.IOException: Unable to read data from the transport connection:A
blocking operation was interrupted by a call to WSACancelBlockingCall"

This error msg is seen when sever thread endless read from network stream.

What does this mean? Can I solve this problem by using async I/O on server
side?
Does client using which type I/O affect server side?

When server thread writes to the network steam, there are also error
soemtime: "System.InvalidOperationException: The operation is not allowed on
non-connected sockets. "
How can I avoid sockets getting disconnected? Is this also due to
"interrupted by a call to WSACancelBlockingCall" error when read from
socket?

-------
One time I used async I/O on sever side and sync I/O on client side, then
the server shuted itself down automatically, later I found there are Trojan
Horse virus in the network. I don't know the server crashs due to my new
code or because of virus . I don't always have the chance to try out my new
code.

That time I also see async new read error on server side when
NetworkStream.EndRead(), but seems it is more reasonable, and I just ignore
and BeginRead again:

" System.IO.IOException: Unable to read data from the transport connection:
A connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed because
connected host has failed to respond. --->
System.Net.Sockets.SocketException: A connection attempt failed because the
connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to respond
at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
at System.Net.Sockets.NetworkStream.EndRead(IAsyncRes ult asyncResult)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.EndRead(IAsyncRes ult asyncResult)

and sometime evern worse error for EndRead():

"System.IO.IOException: Unable to read data from the transport connection:
An existing connection was forcibly closed by the remote host. --->
System.Net.Sockets.SocketException: An existing connection was forcibly
closed by the remote host" -- Is that true? But I didn't write any code on
client side to close the connection until logout.

What all these mean? What makes it so fragile? Where to get started to learn
write more
roburst network program?

Thanks!
Ryan

Jun 27 '08 #1
1 20451
On Tue, 20 May 2008 11:02:53 -0700, Ryan Liu <rl**@powercati.comwrote:
[...]
I frequently see the error on server side(client side code is same, but I
don't see the error):

"System.IO.IOException: Unable to read data from the transport
connection:A
blocking operation was interrupted by a call to WSACancelBlockingCall"
You shouldn't have code using WSACancelBlockingCall. Without a
concise-but-complete code sample that can reliably reproduce that error,
it's not really possible to say how it is you do have code using that
function.
This error msg is seen when sever thread endless read from network
stream.

What does this mean? Can I solve this problem by using async I/O on
server
side?
Does client using which type I/O affect server side?
Well, using async i/o will avoid using blocking calls, which in theory
should prevent a blocking operation from being interrupted by
WSACancelBlockingCall. But since the function shouldn't be getting called
in the first place, it's not clear that's the right solution. It would be
better to find out why your network i/o code is being affected by
functions that should theoretically not be part of your code at all.
When server thread writes to the network steam, there are also error
soemtime: "System.InvalidOperationException: The operation is not
allowed on
non-connected sockets. "
How can I avoid sockets getting disconnected? Is this also due to
"interrupted by a call to WSACancelBlockingCall" error when read from
socket?
Without code, it's hard to say. It's certainly possible that whatever is
causing the problem is also disconnecting your socket. But a socket can
always wind up disconnected for a variety of reasons. While the question
of WSACancelBlockingCall is still in need of pursuing, your code should
always be able to deal with a disconnected socket.
-------
One time I used async I/O on sever side and sync I/O on client side, then
the server shuted itself down automatically, later I found there are
Trojan
Horse virus in the network. I don't know the server crashs due to my new
code or because of virus . I don't always have the chance to try out my
new
code.
Malware certainly has the potential to cause problems like this, depending
on how virulent it is. Malware can introduce all sorts of new
complexities and errors.

Is this your problem? Hard to say without more specifics. If you can
reproduce the problem on a known clean system, then I'd say it's not. If
the problem only ever shows up on a specific computer, then I'd say it
very well could be malware.
That time I also see async new read error on server side when
NetworkStream.EndRead(), but seems it is more reasonable, and I just
ignore
and BeginRead again:
With most errors, you need to simply close the socket and start over.
Very few errors are recoverable, and those that are, are specifically
documented as being recoverable and in fact are more informational than
being actual errors (for example WSAEWOULDBLOCK).
" System.IO.IOException: Unable to read data from the transport
connection:
A connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed because
connected host has failed to respond. --->
Sounds like some sort of timeout. However, you said you're using
synchronous i/o, so I don't know why the stack trace would show only calls
to the async i/o methods.

Generally speaking, unless you've messed with the timeout properties on a
socket or have set keep-alive on the connection, only connection attempts
will timeout. Sends and receives will simply block until interrupted (by
closing the socket) or being completed. If you've done something that
enables timeout behavior on the socket then, well...yes, it could timeout.

Again, without code, it's not possible to say what's actually happening.
[...]
"System.IO.IOException: Unable to read data from the transport
connection:
An existing connection was forcibly closed by the remote host. --->
System.Net.Sockets.SocketException: An existing connection was forcibly
closed by the remote host" -- Is that true? But I didn't write any code
on
client side to close the connection until logout.
"Forcibly terminated" is a way of saying that the connection was reset
ungracefully. This almost always happens _outside_ your code, since
normally people write network code that only closes connections
gracefully. As for why the connection got reset, it's hard to say. It
can happen for a variety of reasons, including a network cable being
disconnected (if the Windows "media detect" setting is enabled) or some
malicious third party somewhere along the line of transmission (for
example, Comcast has been caught forging connection reset packets, causing
TCP connections to be dropped arbitrarily).
What all these mean? What makes it so fragile? Where to get started to
learn
write more roburst network program?
Well, networking is kind of fragile. It relies on a lot of intermediate
components outside your control and your own code needs to anticipate the
kinds of things that can occur.

As for where to start, I'm not really sure. I'm not an expert, and what I
do know I mostly learned "the hard way". :) But one useful place to start
is reading the Winsock FAQ: http://tangentsoft.net/wskfaq/ It's not what
I'd call an exhaustive reference, but it certainly covers most of the most
common issues people new to network programming might need to learn, or
might run into. Winsock isn't the .NET API per se, but it's what the .NET
API is built on, and the socket API defined by Winsock and BSD sockets
(from which Winsock was initially derived) forms the basis for the most
common network APIs you'll run into.

Pete
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert A. van Ginkel | last post by:
In news:OZ0W9RsdDHA.2432@TK2MSFTNGP10.phx.gbl... I ask the question how I can see if all the data is on the other side of the connection. I got as answer that I should use the blocking property. I...
3
by: Logan McKinley | last post by:
I have a C# program that uses blocking sockets and want to allow the user to stop the server. The problem I am having is the socket blocks on...
2
by: Rene | last post by:
Hi, In my VB6 application I'm using a class/object that is using full-async ADO. I can start multiple queries, the class stores the ADODB.Recordset object in an array and waits for the...
7
by: Michi Henning | last post by:
Hi, I'm using a non-blocking connect to connect to a server. Works fine -- the server gets and accepts the connection. However, once the connection is established, I cannot retrieve either the...
1
by: José Joye | last post by:
When I unload my appdomain, I got the following exception: A blocking operation was interrupted by a call to WSACancelBlockingCall: ..... My appdomain uses remoting... From previous post, I...
1
by: Sagaert Johan | last post by:
Hi Ii have a simple server thread in an app that listens for connections, for some unclear reason an exception is thrown every now and then : 'A blocking operation was interrupted by a call to...
10
by: Brian Parker | last post by:
I inherited a C++ DLL that I need to remotely call multiple times asynchronously. What I have developed is: CSharp web application that makes asynchronous calls to a CSharp Web Service. The...
3
by: Bob | last post by:
Hi, I have an app that has a 3rd party phone answering control (4 of ) (interfacing with dialogic 4 line card) attached to the main form. each control raises an event when its Dialogic line...
6
by: Frank Hauptlorenz | last post by:
Hello out there, I have 2 services running. The first one runs in session mode and the 2nd not. The first one should call an operation of the 2nd one asynchronously, because this is doing some...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.