Click here to Skip to main content
15,904,823 members
Home / Discussions / C#
   

C#

 
AnswerRe: speech sdk5.1 Pin
Ravi Bhavnani6-May-06 18:01
professionalRavi Bhavnani6-May-06 18:01 
GeneralRe: speech sdk5.1 Pin
TheEagle6-May-06 22:16
TheEagle6-May-06 22:16 
QuestionOpening PDF file Pin
May Thu san6-May-06 16:36
May Thu san6-May-06 16:36 
AnswerRe: Opening PDF file Pin
Sean896-May-06 17:56
Sean896-May-06 17:56 
Questionproblem with threading Pin
Tahsin Sayeeda6-May-06 15:30
Tahsin Sayeeda6-May-06 15:30 
AnswerRe: problem with threading Pin
Ravi Bhavnani6-May-06 17:57
professionalRavi Bhavnani6-May-06 17:57 
AnswerRe: problem with threading Pin
Shy Agam6-May-06 22:57
Shy Agam6-May-06 22:57 
GeneralRe: problem with threading Pin
Tahsin Sayeeda7-May-06 0:09
Tahsin Sayeeda7-May-06 0:09 
GeneralRe: problem with threading Pin
Shy Agam7-May-06 0:54
Shy Agam7-May-06 0:54 
GeneralRe: problem with threading Pin
Tahsin Sayeeda7-May-06 8:49
Tahsin Sayeeda7-May-06 8:49 
GeneralRe: problem with threading Pin
S. Senthil Kumar7-May-06 2:45
S. Senthil Kumar7-May-06 2:45 
GeneralRe: problem with threading Pin
Tahsin Sayeeda7-May-06 8:33
Tahsin Sayeeda7-May-06 8:33 
GeneralRe: problem with threading Pin
Guffa7-May-06 5:35
Guffa7-May-06 5:35 
AnswerRe: problem with threading Pin
stbaker9-May-06 4:12
stbaker9-May-06 4:12 
QuestionPorting web navigator from VB6 to VS2005 C# Pin
cweeks786816-May-06 14:12
cweeks786816-May-06 14:12 
AnswerRe: Porting web navigator from VB6 to VS2005 C# Pin
cweeks786818-May-06 8:26
cweeks786818-May-06 8:26 
GeneralRe: Porting web navigator from VB6 to VS2005 C# Pin
cweeks786818-May-06 14:22
cweeks786818-May-06 14:22 
Questionnewbie seeks guidance on how use IDE Pin
wheels4me6-May-06 13:16
wheels4me6-May-06 13:16 
AnswerRe: newbie seeks guidance on how use IDE Pin
led mike6-May-06 13:51
led mike6-May-06 13:51 
AnswerRe: newbie seeks guidance on how use IDE Pin
Josh Smith7-May-06 4:51
Josh Smith7-May-06 4:51 
Questionhow to use progressbar ? Pin
hdv2126-May-06 12:22
hdv2126-May-06 12:22 
AnswerRe: how to use progressbar ? Pin
ekynox6-May-06 14:28
ekynox6-May-06 14:28 
QuestionBeginReceive problem (Sockets question) Pin
tmp06-May-06 10:56
tmp06-May-06 10:56 
Hello all,

I'm trying to build my own very-simple Socket wrapper class. The first class (which I'm trying to do now) is for listening. The most important thing I am trying to implement is OnConnect, Ondisconnect, and OnReceive.

I've done OnConnect and it's working perfectly. But now I've spent alot of time trying to implement the OnReceive method, but I get a strange result!

..
..
..
<br />
		public void listen(int port)<br />
		{<br />
			listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);<br />
			listener.Bind(new IPEndPoint(IPAddress.Any, port));<br />
			listener.Listen(10);<br />
			listener.BeginAccept(new AsyncCallback(myOnConnect), listener);<br />
		}<br />
<br />
		public void myOnConnect(IAsyncResult  ar)<br />
		{<br />
			Socket sock = (Socket)ar.AsyncState;<br />
			OnConnect(myId);<br />
			try<br />
			{<br />
				if (sock.Connected) //the strange this is, this always returns false, thus the code below is not executed. And when I take of the conditional statement, I get an exception!<br />
				{<br />
					AsyncCallback recieveData = new AsyncCallback(myOnReceive);<br />
					sock.BeginReceive(m_byBuff, 0, m_byBuff.Length, SocketFlags.None, recieveData, sock);<br />
				}<br />
			}<br />
			catch(Exception e)<br />
			{<br />
				MessageBox.Show("Err: "+e.ToString());<br />
			}<br />
			listener.BeginAccept(new AsyncCallback(myOnConnect), listener);<br />
		}<br />
<br />
		public void myOnReceive(IAsyncResult ar)<br />
		{<br />
			Socket sock = (Socket)ar.AsyncState;<br />
			try<br />
			{<br />
				int nBytesRec = sock.EndReceive(ar);<br />
				if( nBytesRec > 0 )<br />
				{<br />
					string msg = Encoding.ASCII.GetString(m_byBuff, 0,nBytesRec);<br />
					OnReceive(myId, msg);<br />
					AsyncCallback recieveData = new AsyncCallback(myOnReceive);<br />
					sock.BeginReceive( m_byBuff, 0, m_byBuff.Length, SocketFlags.None, recieveData, sock);<br />
				}<br />
				else<br />
				{<br />
					OnDisconnect(myId);<br />
				}<br />
			}<br />
			catch<br />
			{}<br />
		}<br />

AnswerRe: BeginReceive problem (Sockets question) Pin
led mike6-May-06 13:45
led mike6-May-06 13:45 
AnswerRe: BeginReceive problem (Sockets question) Pin
Shy Agam6-May-06 22:44
Shy Agam6-May-06 22:44 

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.