Mixing synchronous and asynchronous socket calls?

Looking at your two examples, I see very little difference (if any at all) in what's occurring. I'd venture that your second form (going straight for the synchronous call) is better because it's far less complicated and is behaviourally identical. If you could look at the source for Accept, at some point (probably in the OS) it will be doing much the same as your more verbose code However A very quick mod to your old code eliminates all blocking and lets everything occur asynchronously: void Accept() { Console.

WriteLine("Waiting for a connection..."); listener. BeginAccept(AcceptCallback, listener); } public static void AcceptCallback(IAsyncResult ar) { Accept(); //bla } mmmm... much better.

Looking at your two examples, I see very little difference (if any at all) in what's occurring. I'd venture that your second form (going straight for the synchronous call) is better because it's far less complicated and is behaviourally identical. If you could look at the source for Accept, at some point (probably in the OS) it will be doing much the same as your more verbose code.However... A very quick mod to your old code eliminates all blocking and lets everything occur asynchronously: void Accept() { Console.

WriteLine("Waiting for a connection..."); listener. BeginAccept(AcceptCallback, listener); } public static void AcceptCallback(IAsyncResult ar) { Accept(); //bla } mmmm... much better.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions