PC Review


Reply
Thread Tools Rate Thread

BeginReceive throws Request Timeout exception for the second call.

 
 
=?Utf-8?B?ZmFrdHVqYWE=?=
Guest
Posts: n/a
 
      7th Aug 2004
Hi All,
I have used the available code snippet from microsoft for socket
communication.
But the following code throws an error mentioned above. Please check the
code and help me asap.
private static void ReceiveCallback(IAsyncResult IResult)
{
try
{
// Retrieve the state object and the client socket from the
asynchronous state
//object.
StateObject objState = (StateObject) IResult.AsyncState;
Socket socClient = objState.msocSocket;

// Read data from the remote device.
int intBytesRead = socClient.EndReceive(IResult);

if(intBytesRead > 0)
{
// There might be more data, so store the data received so far.
objState.msbdDataReceived.Append(Encoding.ASCII.GetString
(objState.mbytBuffer, 0, intBytesRead));

// Get the rest of the data.
socClient.BeginReceive(objState.mbytBuffer, 0,
StateObject.BUFFER_SIZE, 0, new AsyncCallback(ReceiveCallback), objState);
}
else
{
// All the data has arrived; put it in response.
if (objState.msbdDataReceived.Length > 1)
{
mstrResponse = objState.msbdDataReceived.ToString();
}

// Signal that all bytes have been received.
mevtReceiveDone.Set();
}
}
catch(Exception objException)
{
throw objException;
}
}

The problem is that BeginReceive works as long as the Server return data
i.e. for example: Server return A 1st time, B 2nd time and if there is no
more data for the third time and if BeginReceive method is called, it throws
request timeout error.
Thanks in advance.
faktujaa
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
accessing Request.Browser throws an exception germ Microsoft ASP .NET 1 6th Jul 2007 12:12 AM
Timeout call back in asynchronous web request. archana Microsoft C# .NET 2 19th Sep 2006 08:21 AM
Call WebService on Windows 98, random timeout exception azerty Microsoft Dot NET 0 21st Sep 2005 05:06 PM
ReaderWriterLock with low timeout throws unhandled exception Anders Borum Microsoft C# .NET 4 17th Nov 2004 01:41 PM
Changing the value of Session.Timeout triggers a call to Global.asax.Session_End function at end of request Samuel Stanojevic Microsoft ASP .NET 1 15th Sep 2004 04:35 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:39 AM.