.NET Socket *Async methods have a design flaw.

So I was attempting to make use of IO completion ports and build a high performance socket server in C# by making use of the *Async methods such as ReceiveAsync with SocketAsyncEventArgs. However I’ve encountered a problem which I cannot seem to find a solution for which involves a StackOverException being triggered by the execution of these methods. You see, at first glance everything appeared to be humming along nicely, until I decided to flood my server with about 12,000 randomly sized packets. That’s when the problem shows up.

I have a TryReceive method that makes the first call to ReceiveAsync, and if it returns FALSE, then I call the ProcessReceive directly, otherwise it gets called by the Completed event getting invoked on the SocketAsyncEventArgs. ProcessReceive then does some processing of the message and then calls TryReceive to start the process all over again. For whatever reason, the ReceiveAsync is always completing synchronously and creating a recursive loop with my two methods.

I’m not really sure what to try at this point, other than possibly trying to call it on another thread, but I’m worried that might cause some other recursive thread call issues. If anyone has any ideas feel free to hit up my contact form.

Here’s some extracted snippets of code to show how the calls are structured.

Updates

I’m not sure how many people follow my GitHub, but I’ve been learning React and Angular. So far if I had to pick a favorite it would be Angular, I prefer it’s stricter separation of code and markup, and it’s bigger collection of functionality that’s built in. I’ve got another domain (garbagefile.io), that I’ve wanted to do something with for a while, so I’m thinking I’ll build something in Angular and host it on there. My main site will stick with WordPress for right now, unless I get the motivation to rewrite it in Laravel or some other PHP framework.

I’m also working on a new version of my AIM server in .NET Core that should be a lot more scalable and feature rich. I’ve wanted to build it for years now, but I didn’t feel as though I had the skills or the technology stack to do it successfully. My goal would be to have it support up to 5000 connected users at once starting off, and to have it possibly scale up to 500,000 users (highly unlikely to ever get that amount, but I can dream can’t I?). Other goals include having it support AIM 1.x – AIM 5.x, as well as possibly creating plug-ins for those versions to support OSCAR over SSL, and stronger password hashing methods such as Scrypt or BCrypt.

Anyway, I hope to update this site soon with more updates, but if not, I guess i’ll see you next year!

I’m still alive!

I am still alive, and I’ve made a slight update to the About page. I plan to start working on more modern technical projects in the near future. Most of my more recent developments will be posted to GitHub before they get posted on this website.

I recently got a new job at a consulting company writing .NET code full-time, so my creative spark is starting to return.

Attempting to write more code

So I’ve decided to set an ambitious goal of writing some kind of code or documentation every single day and committing it to GitHub. The idea behind this goal is to accelerate and expand my knowledge, as well as avoid the stagnation that can happen the longer you work somewhere. If I’m unable to make at least 1 daily commit to a project, I’d like to meet a weekly goal of at least 7 commits.

In other news, I updated WordPress without first backing up my database; because I like to live dangerously.