Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
GeneralRe: invalidate() in winforms Pin
Josh Smith21-Jul-06 4:09
Josh Smith21-Jul-06 4:09 
GeneralRe: invalidate() in winforms Pin
Judah Gabriel Himango21-Jul-06 6:02
sponsorJudah Gabriel Himango21-Jul-06 6:02 
GeneralRe: invalidate() in winforms Pin
Josh Smith21-Jul-06 8:12
Josh Smith21-Jul-06 8:12 
GeneralRe: invalidate() in winforms Pin
Judah Gabriel Himango21-Jul-06 9:01
sponsorJudah Gabriel Himango21-Jul-06 9:01 
GeneralRe: invalidate() in winforms Pin
Josh Smith22-Jul-06 3:36
Josh Smith22-Jul-06 3:36 
GeneralRe: invalidate() in winforms Pin
Judah Gabriel Himango22-Jul-06 6:49
sponsorJudah Gabriel Himango22-Jul-06 6:49 
QuestionDecoupling components Pin
WillemM21-Jul-06 2:37
WillemM21-Jul-06 2:37 
QuestionC# async Socket howto read nutil buffer is empty Pin
TUX2K21-Jul-06 2:12
TUX2K21-Jul-06 2:12 
I have been searching the net, the code project en google.
But I just cant find an answer to my question:
I create a ansync sokcet connection adn use BeginRead te read data from the socket.
like this:
/// <summary><br />
/// Tell the stream to recieve data<br />
/// </summary><br />
private void Receive(){<br />
  _Stream.BeginRead(_Buffer, _Offset, _Count, new AsyncCallback( RecieveCallBack ), _Stream);<br />
}<br />
		<br />
/// <summary><br />
/// The steam has received data<br />
/// </summary><br />
/// <param name="asyncResult"></param><br />
private void RecieveCallBack( IAsyncResult asyncResult ){<br />
	try{<br />
		int _ReceivedBytes;<br />
		_ReceivedBytes =  _Stream.EndRead( asyncResult); <br />
		if( _RecievedBytes > 0 )<br />
		{<br />
			string data = System.Text.Encoding.UTF8.GetString( _Buffer, _Offset, _RecievedBytes);<br />
			<br />
			//Lets pass the data on to the OnRecive event<br />
			FireOnReceive(data);<br />
			// Call recieve to setup the beginread<br />
			if ( IsConnected )<br />
				Receive();<br />
		}<br />
	} catch(ObjectDisposedException) {<br />
		// The object is already Disposed<br />
		// there is nothging more to do<br />
		return;<br />
	} catch(System.IO.IOException e) {<br />
		FireOnError( new ConnectionException(e.Message , ConnectionErrorType.ReceiveError ) );<br />
		}<br />
}


The problem is that it reads only as much as the _Offset allows, this is set 1024 byte.
But if the received is bigger than the offset the socket blocks and i only get half the data i need.
How do I get the complete data form the socket, I looked at some examples on code project bud they all us other method of getting the data form the socket object.

-- modified at 8:29 Friday 21st July, 2006
AnswerRe: C# async Socket howto read nutil buffer is empty [modified] Pin
WillemM21-Jul-06 2:45
WillemM21-Jul-06 2:45 
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 

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.