Click here to Skip to main content
15,922,584 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# async Socket howto read nutil buffer is empty [modified] Pin
WillemM21-Jul-06 2:45
WillemM21-Jul-06 2:45 
Here's a simplified sample for the received callback.
You forgot the resume reading from the stream. This causes the application to stop receiving data. Also you use the offset, this isn't necessary since you simply fill the receive buffer again from the start.

private void dataReceived(IAsyncResult asyncResult) {<br />
  //Stop reading<br />
  _receivedbytes = _stream.EndRead(asyncResult);<br />
  <br />
  //Process received data<br />
  string data = parseData(_buffer,0,_receivedbytes);<br />
  <br />
  //Start reading again<br />
  _stream.BeginRead(_buffer,0,_bufferlength,new AsyncCallback(dataReceived));<br />
}


WM.

What about weapons of mass-construction?

-- modified at 8:45 Friday 21st July, 2006
GeneralRe: C# async Socket howto read nutil buffer is empty Pin
TUX2K21-Jul-06 3:08
TUX2K21-Jul-06 3:08 
GeneralRe: C# async Socket howto read nutil buffer is empty Pin
WillemM21-Jul-06 3:11
WillemM21-Jul-06 3:11 
GeneralRe: C# async Socket howto read nutil buffer is empty Pin
TUX2K21-Jul-06 3:51
TUX2K21-Jul-06 3:51 
GeneralRe: C# async Socket howto read nutil buffer is empty Pin
WillemM21-Jul-06 4:28
WillemM21-Jul-06 4:28 
GeneralRe: C# async Socket howto read nutil buffer is empty Pin
TUX2K21-Jul-06 4:53
TUX2K21-Jul-06 4:53 
QuestionPlayout Video Pin
shakil ahmed21-Jul-06 1:57
shakil ahmed21-Jul-06 1:57 
AnswerRe: Playout Video Pin
LongRange.Shooter21-Jul-06 4:50
LongRange.Shooter21-Jul-06 4:50 
GeneralRe: Playout Video Pin
shakil ahmed21-Jul-06 21:00
shakil ahmed21-Jul-06 21:00 
QuestionControl events Pin
venkatchowdary21-Jul-06 1:34
venkatchowdary21-Jul-06 1:34 
QuestionVideo Streaming Problem Pin
shakil ahmed21-Jul-06 1:28
shakil ahmed21-Jul-06 1:28 
AnswerRe: Video Streaming Problem Pin
stancrm21-Jul-06 1:32
stancrm21-Jul-06 1:32 
AnswerRe: XMLReader Problem Pin
stancrm21-Jul-06 1:35
stancrm21-Jul-06 1:35 
QuestionProperties.Settings.Default.Save() does not work Pin
Mertli Ozgur Nevres21-Jul-06 1:06
Mertli Ozgur Nevres21-Jul-06 1:06 
AnswerRe: Properties.Settings.Default.Save() does not work Pin
Mertli Ozgur Nevres21-Jul-06 1:52
Mertli Ozgur Nevres21-Jul-06 1:52 
QuestionUnauthorizedAccessException Pin
sjembek20-Jul-06 23:55
sjembek20-Jul-06 23:55 
AnswerRe: UnauthorizedAccessException Pin
leppie21-Jul-06 1:02
leppie21-Jul-06 1:02 
GeneralRe: UnauthorizedAccessException Pin
sjembek21-Jul-06 1:27
sjembek21-Jul-06 1:27 
GeneralRe: UnauthorizedAccessException Pin
leppie21-Jul-06 2:10
leppie21-Jul-06 2:10 
AnswerRe: UnauthorizedAccessException Pin
Vasudevan Deepak Kumar21-Jul-06 1:41
Vasudevan Deepak Kumar21-Jul-06 1:41 
GeneralRe: UnauthorizedAccessException Pin
sjembek21-Jul-06 2:06
sjembek21-Jul-06 2:06 
Questionnamevaluecollection in user settings Pin
Badscher20-Jul-06 23:22
Badscher20-Jul-06 23:22 
AnswerRe: namevaluecollection in user settings Pin
Badscher21-Jul-06 1:41
Badscher21-Jul-06 1:41 
AnswerRe: namevaluecollection in user settings Pin
LongRange.Shooter21-Jul-06 4:48
LongRange.Shooter21-Jul-06 4:48 
QuestionIsolatedStorageFile.GetStore() problem Pin
Super Lloyd20-Jul-06 23:12
Super Lloyd20-Jul-06 23:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.