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: 341

Filed under:
|
|

Error: Unable to read data from the transport connection: A blocking operation was interrupted by a call to WSACancelBlockingCall

Situation

  1. There is a TCP Server
  2. 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;
    
  3. 2 Users use the same application from two different location to access information from this server at the SAME TIME

  4. Server takes around 2sec to reply
  5. Both Connect
  6. 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?

  1. Use a better way of connecting to the server
  2. 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

Related posts about tcpip

Related posts about c#