Unable to make 2 parallel TCP requests to the same TCP Client
Posted
by soldieraman
on Stack Overflow
See other posts from Stack Overflow
or by soldieraman
Published on 2009-10-09T01:51:04Z
Indexed on
2010/05/01
21:37 UTC
Read the original article
Hit count: 343
Error: Unable to read data from the transport connection: A blocking operation was interrupted by a call to WSACancelBlockingCall
Situation
- There is a TCP Server
My web application connects to this TCP Server
Using the below code:
TcpClientInfo = new TcpClient(); _result = TcpClientInfo.BeginConnect(<serverAddress>,<portNumber>, null, null); bool success = _result.AsyncWaitHandle.WaitOne(20000, true); if (!success) { TcpClientInfo.Close(); throw new Exception("Connection Timeout: Failed to establish connection."); } NetworkStreamInfo = TcpClientInfo.GetStream(); NetworkStreamInfo.ReadTimeout = 20000;
2 Users use the same application from two different location to access information from this server at the SAME TIME
- Server takes around 2sec to reply
- Both Connect
- But One of the user gets above error "Unable to read data from the transport connection: A blocking operation was interrupted by a call to WSACancelBlockingCall" when trying to read data from stream
How can I resolve this issue?
- Use a better way of connecting to the server
- Can't because it's a server issue
- if a server issue, how should the server handle request to avoid this problem
© Stack Overflow or respective owner