473,813 Members | 3,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A blocking operation was interrupted by a call to WSACancelBlocki ngCall -- 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.IOEx ception: Unable to read data from the transport connection:A
blocking operation was interrupted by a call to WSACancelBlocki ngCall"

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.Invalid OperationExcept ion: The operation is not allowed on
non-connected sockets. "
How can I avoid sockets getting disconnected? Is this also due to
"interrupte d by a call to WSACancelBlocki ngCall" 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.E ndRead(), but seems it is more reasonable, and I just ignore
and BeginRead again:

" System.IO.IOExc eption: 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.Sock ets.SocketExcep tion: 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.Sock ets.Socket.EndR eceive(IAsyncRe sult asyncResult)
at System.Net.Sock ets.NetworkStre am.EndRead(IAsy ncResult asyncResult)
--- End of inner exception stack trace ---
at System.Net.Sock ets.NetworkStre am.EndRead(IAsy ncResult asyncResult)

and sometime evern worse error for EndRead():

"System.IO.IOEx ception: Unable to read data from the transport connection:
An existing connection was forcibly closed by the remote host. --->
System.Net.Sock ets.SocketExcep tion: 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 20650
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.IOEx ception: Unable to read data from the transport
connection:A
blocking operation was interrupted by a call to WSACancelBlocki ngCall"
You shouldn't have code using WSACancelBlocki ngCall. 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
WSACancelBlocki ngCall. 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.Invalid OperationExcept ion: The operation is not
allowed on
non-connected sockets. "
How can I avoid sockets getting disconnected? Is this also due to
"interrupte d by a call to WSACancelBlocki ngCall" 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 WSACancelBlocki ngCall 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.E ndRead(), 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.IOExc eption: 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.IOEx ception: Unable to read data from the transport
connection:
An existing connection was forcibly closed by the remote host. --->
System.Net.Sock ets.SocketExcep tion: 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
3712
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 tried this I don't see any diffents, I am sending 10Mb and the Send/BeginSend command doesn't wait till the data is on the remotepoint. Can somebody pls. explain this. Regards Robert.
3
10405
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 -------------------------------------------------------------- listener = new System.Net.Sockets.TcpListener(6254); listener.Start(); //skt is a socket skt =listener.AcceptSocket(); <--- this line blocks -------------------------------------------------------------- I attempt to stop the thread...
2
2259
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 QueryComplete event. This will set the result and flag 'the query is finished' in the array. In my WaitForResult() method I wait till the flag 'query is finished' is set and return to the caller. While waiting I'm calling DoEvents and delay
7
17421
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 local or the remote endpoint from the client-side socket. The *really* strange thing is that Socket.LocalEndPoint is null. According to the doc, that's impossible: reading the LocalEndPoint
1
2764
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 know that I should call "RemotingServices.Disconnect" to close the remoting channel while unloading my appdomain. However, when I pass my object (say m_remote), there is an exception telling:
1
22814
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 WSACancelBlockingCall ' Any suggestion why this may happen ? The Exception is thrown by the svr.AcceptTcpClient() method See source below.
10
2642
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 Web Service calls the DLL, which does some heavy processing, then sends the results back to the CSharp web application. The problem is that the calls to the DLL in the Web Service are blocking each other. If I send 10 async requests to the Web...
3
3292
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 detects ring tone. I use the ring detect event handler to create a new thread which is given a reference to the control that is being rung. The called method then interacts with the control until the call finishes. My problem is that I believe I am...
6
2622
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 long running calculations. If this call is synchronously, everything is running okay. If it's call async the operation does not even start. (I've setup up some event log message at the entry point).
0
9734
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10669
Oralloy
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...
1
10426
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10141
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9225
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5570
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...
0
5707
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3886
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3030
bsmnconsultancy
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...

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.