Jump to content
  • Advertisement
Sign in to follow this  
Kryptus

[.net] Async Socket Flow of Data

This topic is 4670 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have the following line of code: mySocket.BeginReceive(buffer, 0, BufferSize, 0, new AsyncCallback(this.ReadCallback), null); The problem I have is once this is used once, it's never used again obviously and continues on. What I'm asking is what is the best way to keep recieving data even after data has been recieved? mySocket.BeginReceive(buffer, 0, BufferSize, 0, new AsyncCallback(this.ReadCallback), null); mySocket.BeginReceive(buffer, 0, BufferSize, 0, new AsyncCallback(this.ReadCallback), null); mySocket.BeginReceive(buffer, 0, BufferSize, 0, new AsyncCallback(this.ReadCallback), null); mySocket.BeginReceive(buffer, 0, BufferSize, 0, new AsyncCallback(this.ReadCallback), null); This would recieve data 4 times as you can see. Would a loop then be wise or not? If I used a loop would I have to sleep threads or DoEvents? Please discuss.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Put the next BeginReceive in the ReadCallback method.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!