Socket Servers
Information about the JetByte socket server framework.
XML RSS feed for this category.
[Valid RSS]


SSPI Negotiation; NTLM and Kerberos clients and servers Posted by Len at 22 Jun 2009 09:04 PM
I've been working on a library that works in a similar way to our SChannel code and allows the use of the Microsoft "Negotiate" Security Support Provider Interface (SSPI) to provide NTLM and Kerberos support (see SPNEGO for more details)....


Where's the catch(...) Posted by Len at 19 Jun 2009 10:03 AM
As of the next release of the server framework use of catch(...) handlers at thread boundaries, in 'no throw' functions and in destructors will be configurable. At present, in v6.0 and earlier of the server framework, we use catch(...) judiciously...


Allocating page aligned buffers Posted by Len at 14 Jun 2009 07:20 PM
Back in October 2007 I briefly looked at, what seemed to be at the time, a simple change to the server framework so that you had the option to use buffers that were aligned to page boundaries. This could help...


Structured exception translation is now optional Posted by Len at 13 Jun 2009 09:30 AM
I've had a couple of requests from clients recently that they be able to handle any structured exceptions in the server framework themselves. Up until now all framework threads install a SEH translator and catch the resulting C++ exceptions in...


Why not to compile as 64 bit... Posted by Len at 11 Jun 2009 02:06 PM
Here's a nice piece by Rico Mariani about why Visual Studio is unlikely to go 64 bit any time soon. In a nut shell, unless you have very large data sets that need to be kept in memory you might...


New Windows Services library Posted by Len at 10 Jun 2009 09:48 AM
I'm currently working on a new version of the Windows Services library that ships as part of the Licensed I/O Completion Port Server Framework. The Services library allows you to turn your server into a Windows Service very easily and...


Race condition during service shutdown Posted by Len at 1 Jun 2009 09:47 AM
There's a race condition in the service shutdown code which is most likely to show up if there's an exception thrown from your implementation of ContinueService(), PauseService() or StopService() but that could show up during any service shutdown sequence. This...


Bug fix in performance counter instance activation code Posted by Len at 1 Jun 2009 08:59 AM
There's a bug in all releases of our performance counter library that may cause the creation of an instance with a name that has been previously used as an instance but that has been released to fail by connecting the...


Everything you need to know about timers and periodic scheduling in the server framework Posted by Len at 5 May 2009 01:25 PM
Often when you're writing a server or client application with the framework you will find yourself needing to perform operations periodically or after a timeout. The framework provides a light weight timer queue that can be used to schedule timers...


May your software scale, and other curses... Posted by Len at 28 Apr 2009 01:16 PM
I'm in the process of upgrading another client to v6.0. These guys write multi-user game systems and have a fairly complex CLR hosting custom application server. Anyway, I was hoping that we'd have a few easy performance wins from the...


Interesting piece on thread pools Posted by Len at 21 Apr 2009 08:48 AM
Herb Sutter has just published an interesting article over at DDJ on correctly using thread pools: Use Thread Pools Correctly: Keep Tasks Short and Nonblocking. It's not rocket science and it doesn't deal with platform issues but it's a useful...


Bug fix for the free server framework code Posted by Len at 21 Apr 2009 08:42 AM
A user of my free server framework code has reported an error and supplied a fix. The problem is that he's been having connections closing and returning ERROR_CONNECTION_ABORTED and the free code doesn't handle this situation very well and this...


Custom application servers Posted by Len at 15 Apr 2009 09:31 AM
A lot of the custom development work that we do for our customers can be classified as developing 'custom application servers'. Development for these kinds of servers usually requires that we design a wire-protocol for communications between the clients and...


Upgrading to version 6.0 Posted by Len at 2 Apr 2009 12:02 PM
I'm in the process of upgrading a set of ISO8583 servers for a client. One of these is the original server that caused the server framework to come into existence back in 2002. The other two servers are based on...


Excellent article on Non-Paged Pool Posted by Len at 27 Mar 2009 11:45 AM
Mark Russinovich has an excellent piece (here) on how 'non-paged pool' memory sizes are calculated for various versions of Windows operating systems. As those of you who are dealing with high performance, high connection, server systems know, non-paged pool is...


Highlights of the 6.0 server framework release Posted by Len at 26 Mar 2009 04:20 PM
The latest, 6.0, release of the server framework is significant for me in several ways. From a purely practical point of view it's the first release from my new Subversion repository and as such it's the culmination of a fair...


Latest release of licensed socket server code: 6.0 Posted by Len at 26 Mar 2009 04:07 PM
The latest release of the licensed version of the socket server framework is now available. This release includes the following changes. The following changes were made to the libraries. Admin Library - 6.0 Added back the Admin\VC6Compatibility directory with sal.h...


Automatically pruning empty log files Posted by Len at 10 Mar 2009 09:44 AM
The log file rotation code that I wrote a while back has been working well for several clients. Recently someone suggested that the design of their server's logging meant that they tended to generate lots of useful information on server...


Testing SChannel code Posted by Len at 18 Feb 2009 02:29 PM
I developed the new SChannel SSL adapter for our server framework in a mostly test driven style; a while ago I called this Just In Time Testing... It worked well and, to be honest, I couldn't imagine developing code as...


Memory leak in SChannel SSL code Posted by Len at 16 Feb 2009 11:09 AM
I've just had a memory leak in the SChannel SSL code reported by a client. It's a fairly fundamental leak has highlighted an omission in the mock buffer allocators that I use to test this kind of code; it also...


Latest release of licensed socket server code: 5.2.5 Posted by Len at 29 Jan 2009 11:10 AM
The latest release of the licensed version of the socket server framework is now available. This release includes the following changes. The following changes were made to the libraries. Admin Library - 5.2.5 No Change. C++ Tools Library - 5.2.5...


Bug in the dispatching of OnConnectionClosed() in release 5.2.4 of the server framework Posted by Len at 29 Jan 2009 08:31 AM
A client has just reported a bug in version 5.2.4 of the server framework. The bug has, possibly, been present since 5.2.2 and relates to the dispatch of OnConnectionClosed() callbacks when a socket is released. If a socket is still...


Shared locks and unique locks Posted by Len at 23 Dec 2008 11:12 AM
In one of the original articles that introduced the socket server framework I mentioned that the original design was possibly lacking in that it required a critical section per connection and that this could be resource intensive. Shortly after I...


Latest release of licensed socket server code: 5.2.4 Posted by Len at 9 Dec 2008 11:51 AM
The latest release of the licensed version of the socket server framework is now available. This release includes the following changes. The following changes were made to the libraries. Admin Library - 5.2.4 We no longer support Visual Studio 6....


Lock contention Posted by Len at 21 Oct 2008 10:43 AM
I had reason to run my deadlock detection tool on a server built with an old version of the server framework as I needed to make changes to the server's locking strategy and I wanted to make sure that I...


Goodbye old friend Posted by Len at 17 Oct 2008 04:54 PM
As of release 5.2.4, which is due for release in December, we will no longer support Visual Studio 6 builds of the server framework. I've recently had to deal with some weird multi-threaded problems for a client and upgrading them...


Asynchronous SChannel Servers Posted by Len at 9 Oct 2008 01:49 PM
I'm currently working on an SChannel version of the asynchronous SSL connector code that we use to provide SSL support in the server framework. This will eventually be an alternative to the existing OpenSSL support that we currently provide and...


How does the socket server framework compare to Boost::ASIO? Posted by Len at 24 Sep 2008 09:23 AM
I've had a few questions from users and potential users of the JetByte server framework about how it compares to other available frameworks. One such framework is ASIO. The first thing to realise is that the JetByte framework and ASIO...


Log file rotation Posted by Len at 5 Sep 2008 05:08 PM
I'm in the process of adjusting the asynchronous file log that we use in some of our servers. The log works well and write performance is good for a variety of reasons that I deal with here. The current changes...


Connection collections Posted by Len at 2 Sep 2008 10:30 AM
One of the questions that comes up time and again from users of my server framework is "How to I access the list of current connections within the framework". My answer is, you don't, you build your own collection and...


Documentation bug... Posted by Len at 6 Aug 2008 08:37 AM
I realised this morning that part of my "The life of a stream socket connection" document about the safe use of server callbacks in my server framework was wrong. I said this: At any time after a connection is established,...


The life of a stream socket connection Posted by Len at 3 Aug 2008 01:51 PM
As I mentioned here I've recently adjusted how socket callbacks are dispatched in the licensed version of the code......


Latest release of licensed socket server code: 5.2.3 Posted by Len at 3 Aug 2008 12:25 PM
The latest release of the licensed version of the socket server framework is now available. This release includes the following changes. The following changes were made to the libraries. Some whitespace changes to remove incorrect tabs. Admin Library - 5.2.3...


There will be a 5.2.3, or documenting leads to refactoring... Posted by Len at 29 Jul 2008 10:08 AM
I started to document part of the server framework's behaviour as I expect that a client will be asking questions about it in the near future. Whilst writing the documents I found myself writing this: "It's pretty easy to deadlock...


Server shutdown in 5.2.1 and 5.2.2 Posted by Len at 23 Jul 2008 02:10 PM
There was a change in release 5.2.1 of the licensed server framework which has caused some issues with clean shutdown. This issue is also present in 5.2.2. Prior to 5.2.1 the CSocketServer or equivalent object that did the bulk of...


Memory leak in licensed socket server code Posted by Len at 23 Jul 2008 08:23 AM
Well, of course, the day after I released the 5.2.2 version of the server code I get a bug report from a client using 5.2.1 listing a couple of memory leaks. One of them fixed in 5.2.2 and one not....


Latest release of licensed socket server code: 5.2.2 Posted by Len at 21 Jul 2008 12:45 PM
The latest release of the licensed version of the socket server framework is now available. This release includes the following changes. This is the first release built using Compuware BoundsChecker and there have been some resource leaks fixed. The following...


Write completion flow control Posted by Len at 6 Jul 2008 10:31 AM
I've finished the write completion driven outbound data flow control connection filter that I started work on a while ago. This provides a way to deal with the problem of having more data to send to a client than the...


High throughput, low latency Posted by Len at 25 Jun 2008 08:28 AM
As I said in my recent posting about Data Distribution Servers, "Next on the list is writing a more focused server and clients." . Tick. I started out by writing the data feed. This was a simplified version of the...


Data distribution servers Posted by Len at 17 Jun 2008 08:09 PM
Many of the servers built from my socket server framework are for high number of connections and low data flow situations and as such that's where the focus has been on the framework development and testing. As I've shown in...


Another ISO 8583 transaction server Posted by Len at 3 Jun 2008 01:11 PM
It has been a busy couple of weeks for me. I've been working on an ISO 8583 based transaction server for a client and I set myself some fairly tight deadlines. I actually developed the first version of the server...


Socket connection termination Posted by Len at 28 Apr 2008 06:05 PM
I've been putting together a sample server for a client that shows how to cleanly terminate a socket connection. This should have been a simple thing to do, but in doing so I've discovered some gnarlyness within the framework and...


Latest release of licensed socket server code: 5.2.1 Posted by Len at 18 Feb 2008 11:17 AM
The latest release of the licensed version of the socket server framework is now available. This release includes the following changes. All code now builds with VC6, VS2002, VS2003, VS2005 and VS2008. The VS2005 and VS2008 builds support x86 and...


Major Vista Overlapped I/O change Posted by Len at 18 Feb 2008 08:17 AM
I'm still reading the Richter book, highly recommended even if you've read one of the earlier versions. In fact it's possibly MORE highly recommended IF you've read one of the earlier versions... It seems that lots of things have changed...


Major Vista Overlapped I/O change Posted by Len at 18 Feb 2008 08:17 AM
I'm still reading the Richter book, highly recommended even if you've read one of the earlier versions. In fact it's possibly MORE highly recommended IF you've read one of the earlier versions... It seems that lots of things have changed...


Living with continuous integration Posted by Len at 31 Jan 2008 08:48 AM
Well, it's about a month since I started running Cruise Control .Net and things have settled down somewhat now and I can almost go a day or two without tweaking my configuration or being tempted to fix issues in Cruise...


Potential deadlock bug in free socket server framework Posted by Len at 12 Jan 2008 01:19 PM
The free version of the socket server framework contained code that could cause a deadlock during connection closure if you also have a lock in your derived class. There's a lock taken out in CSocketServer::Socket::IsValid() that isn't really required and...


New release of free Socket Server framework Posted by Len at 10 Jan 2008 03:13 PM
There's a new release of the server framework here. This includes the bug fix that was mentioned here....


How important is VC6 to you now? Posted by Len at 10 Jan 2008 09:23 AM
I'm working on the next releases of the licensed version of the socket server framework, and I now have continuous integration (of a sort) so my build and test problems are being minimised... BUT... Keeping Visual Studio 6 support in...


Socket write sequencing memory leak bug in free version of socket server framework Posted by Len at 10 Jan 2008 09:14 AM
I've been tracking a bug for a client recently and yesterday I got a remarkably similar bug report from one of the users of my free socket server framework. The client's code is pretty old and was originally based on...


Performance counter mismatch detection Posted by Len at 13 Dec 2007 11:21 PM
One of the problems with iterative development of servers that include performance counters is that it's quite easy for the counters that are installed on a machine to get out of sync with the counters that the server is actually...


Bug in overlapped UDP port unreachable errors? Posted by Len at 3 Dec 2007 09:19 AM
I'm currently fixing a bug in the UDP side of the server framework. The problem is that I'm failing to handle how Winsock reacts when an overlapped SendTo() results in an ICMP Port Unreachable response from the remote host. This...


VS 2008 Posted by Len at 29 Nov 2007 10:50 AM
I'm currently rebuilding my world with Visual Studio 2008. So far things are going ok, but as I mentioned back when I was playing with Beta 2, the new C4627 warning about header files being skipped when processing precompiled headers...


Performance counters that don't show up in perfmon Posted by Len at 26 Oct 2007 10:08 AM
My current server development for a client has been going well but this week I finally got to the point where I wanted to look at the peformance counters it was presenting and they weren't showing up in perfmon. My...


OnSocketReleased() weirdness Posted by Len at 24 Oct 2007 08:48 AM
I ran into an unexpected issue with OnSocketReleased() yesterday whilst writing a connection filter for a client. OnSocketReleased() is a callback method in the server framework that allows you to 'do stuff' at the last possible moment of a connection's...


Continuing a theme... Posted by Len at 16 Oct 2007 09:15 AM
Continuing last week's theme of being wrong, 'M' pointed out to me in a comment on my posting about changing the memory allocation strategy for the IO buffer allocator that I actually have a bit more work to do... I'd...


IOBuffer allocation strategy... Posted by Len at 12 Oct 2007 11:39 AM
Whilst being wrong this week I reviewed some of the other socket server entries on this site and was reminded of an item that's on a todo list somewhere by a comment on this posting from Matt: "What do you...


Being wrong. Posted by Len at 12 Oct 2007 10:37 AM
This week I've spent some of the time being wrong, which has proven useful as I've learned quite a lot and clarified my understanding of a situation. It all began when I had a bug report from a client who...


x64, IOCP, Socket Server framework Posted by Len at 3 Oct 2007 09:18 AM
The x64 version of our I/O completion port based, networking client and server framework is now shipping. This is the licensed version of the free server framework that's available here. An overview of the licensed version can be found here....


Spolsky's law stikes again... Posted by Len at 19 Sep 2007 05:11 PM
I'm finalising the testing of my x64 socket server framework release and, since it's a fairly major release, I figured that it waranted an email to existing customers to see who wanted to have the update shipped to them straight...


Hosting .Net takes me back to the 'Good ol' days of COM' Posted by Len at 31 Jul 2007 01:15 PM
It's interesting, no, really, how the more things change the more they stay the same... I've been doing COM for a long time. I first discovered COM back at Interlink when I was writing a windows version of a product...


Sometimes it almost seems that they don't want you to get the code to work... Posted by Len at 24 Jul 2007 10:32 PM
I've spent some time over the last few days playing around with my CLR hosting socket server example. I had stalled on a piece of client work, I've got a bit of a head cold at the moment and my...


Unsequenced socket bug fix Posted by Len at 24 Jul 2007 01:51 PM
I've just fixed a bug in the latest version of the socket server framework code (v5.1 - if you dont have docs and a version number then you're CStreamSocket has a RequestWrite() method that takes a BYTE * and a...


Performance counter rewrite almost complete Posted by Len at 17 Jul 2007 05:54 PM
Around a week ago I started looking at rewriting my performance counter library so that it worked on Vista. That work is almost complete and I'm at the stage where the new library does everything the old one did but...


Reliable UDP Posted by Len at 27 Jun 2007 10:02 PM
I've been doing some work for a client on their reliable UDP implementation. It's been interesting stuff. They had picked out a 'best of breed' open source, reliable UDP protocol implementation which was in 'C' and integrated it into their...


Pluggable log systems Posted by Len at 27 Jun 2007 09:29 PM
In the past I've mentioned my lack of enthusiasm for the normal 'debug trace' files that some systems seem to include... I pretty much consider them a design smell... But, some of my clients seem to like them and over...


x64 port - a diversion Posted by Len at 14 Jun 2007 12:44 PM
The x64 port of the socket server framework is going well. I've run the tests for the OpenSSL servers and things are looking good there; this is always an important stage to get to for me as these servers and...


IPv6 support - in anger... Posted by Len at 13 Jun 2007 05:31 PM
Whilst the server framework has supported IPv6 for a while now I haven't really used the functionality a great deal. My previous development box didn't have IPv6 installed and so I never really got around to playing with it. Since...


Performance counter installation on Vista Posted by Len at 13 Jun 2007 01:32 PM
I've been aware that there was a 'need to run as Administrator' issue with some of my server examples for a while; only the ones that installed/removed performance counter dlls or installed/removed themselves as Windows Services. The service installation problem...


x64 Socket Server framework Posted by Len at 7 Jun 2007 05:27 PM
My new development box arrived last week. It's a bit of a monster, dual processor (Intel Xeon E5320 quad core, 1.86 GHz), 8GB ram, and it runs 64bit Vista very nicely indeed. Since it's an x64 box I have started...


Graceful close bug... Posted by Len at 10 May 2007 06:56 PM
It seems that the latest changes to the socket server framework have managed to flush out a graceful shutdown bug that's been floating around since day 0. There's this whole, complex, way of determining how a socket is shutdown and...


cvs update -j Posted by Len at 10 May 2007 10:37 AM
I've finally got to the point where my latest socket server refactoring can be merged back to the main development branch. The changes grew from just being a "remove inappropriate use of pointers where references would be better" to a...


A design that is both too simple and too complex at the same time Posted by Len at 30 Apr 2007 07:48 AM
Except of course, the refactored filters can't actually be layered that well using the design that I outlined in the previous blog posting....


Filtering and layering functionality onto a TCP byte stream Posted by Len at 26 Apr 2007 04:50 PM
As I mentioned a while back, the interface that user code had to our socket server framework was somewhat jumbled and, in fact, consisted of three interfaces that were mashed together. I've been teasing these apart and in doing so...


Cohesive interfaces Posted by Len at 18 Apr 2007 10:20 AM
Of course, once I'd teased apart the callback interface so that it was separate, clear and easy to use and document I realised that it was, in fact, 3 interfaces all jumbled together. They're actually quite easy to spot, there...


Socket Server code - refactoring Posted by Len at 17 Apr 2007 04:12 PM
After spending some time cleaning up and refactoring away the need to derive from concrete classes in the Win32 and IO libraries I finally reached the Socket library and applied the same transformations to the interfaces there. This is actually...


Taking my own advice Posted by Len at 22 Mar 2007 01:05 PM
I'm in the middle of making some changes to the socket server framework, working through my list of things to do whilst I get my head around my next project; some LSP development... The current change is one that I...


Echoes from the CLR Posted by Len at 20 Mar 2007 12:51 PM
The work on the CLR hosting socket server example is going pretty well. I now have a server that can pass server notifications to managed code that either runs in an AppDomain per connection or within a single AppDomain (depending...


Socket Server that hosts the CLR Posted by Len at 15 Mar 2007 05:49 PM
My investigations into CLR hosting are going well and today I built an echo sever based on my latest server framework and my CLR Hosting helper library. The idea is that the server can deal with the network IO and...


So, what's the difference between the free code and the licensed version? Posted by Len at 14 Mar 2007 03:32 PM
People often ask me what the difference is between the free code that's available on this website and the licensed version; this is what I reply......


UDP Multicast Posted by Len at 14 Mar 2007 03:10 PM
The licensed version of the server framework now includes UDP multicast. There are a couple of new examples; a server that joins a multicast group and a client that sends to a multicast group....


Socket Server code: AcceptEx server memory leak Posted by Len at 5 Feb 2007 10:21 AM
The latest version of the licensed socket server framework contains a memory leak in the CSocketServerEx class. It's quite a good leak, it leaks an IO buffer on every connection attempt. The fix is as follows: Change this code:void CStreamSocketServerEx::PostAcceptRequest()...


Socket Server code: Connection termination race condition bug Posted by Len at 31 Jan 2007 03:12 PM
I've just fixed a problem with the licensed version of the socket server code that was reported to me by one of my clients. There's a race condition during connection establishment which can be demonstrated by a client that connects...


Question from a reader Posted by Len at 30 Nov 2006 08:08 PM
I've just had an question from a reader via email: "I'm developing my huge server (I dont have much experience with programming servers) and as far as I know your source is the best available out there.. I would like fit it to my needs and use more c++ standard template libary instead of those buffer/linked list classes you made by yourself, but I'm afraid it would end in loss of preformance speed.. Would it be okay/worse to use instead of your buffer class and instead of those nodes? I also use boost libaries and would definetly include them in the project.. Do you think it would be a bad idea?" and I thought it would be beneficial to reply here rather than via email so that I don't get asked again ;)


Socket Server Code - async connect failure handling change Posted by Len at 8 Nov 2006 05:44 PM
I've just made a small change to the licensed version of the socket server code. The change is in how the AsyncConnect() function reports connection errors and the potential problem can occur if there's a race condition between a call...


Socket Server code - addressing bug fix Posted by Len at 27 Oct 2006 12:40 PM
There's a bug in one of the constructors for CSocket::InternetAddress which means that changing the example servers to use a specific network adapter's address, rather than INADDR_ANY will generate an exception from the call to bind which says that the...


Latest release of socket server code Posted by Len at 14 Feb 2006 08:40 AM
This is the latest release of the free version of my asynchronous, windows, IOCP based, socket server framework. The previous release is here. The latest release is really just a bug fix and compiler compatability release. The code now supports...


More on the socket server VS2005 "leaks" Posted by Len at 10 Feb 2006 06:33 PM
A while ago I reported that I'd been seeing very strange memory usage patterns in the debug build of the simple echo server when built with Visual Studio 2005 using the standard version of STL that ships with it. The...


More on Windows Networking resource limit server failures Posted by Len at 19 Nov 2005 08:48 AM
My VoIP client has been stress testing the UDP version of my socket server framework and they had what they thought was a deadlock. It wasn't a deadlock it was more of a lazy server... What seemed to have happened...


TCP/IP Server Failures Posted by Len at 4 Nov 2005 09:30 AM
One of the good things about the server performance testing that I've been doing recently is that I have been able to witness some rather rare failure conditions in action and seen how the server framework handles them....


Simple Echo Servers Posted by Len at 3 Nov 2005 03:12 PM
A long time ago when I wrote my first article on high performance TCP/IP servers for Windows using IO Completion ports over on CodeProject I complained that "Also the more complicated examples, ones that used IO completion ports for example,...


Windows TCP/IP Server Performance Posted by Len at 3 Nov 2005 12:18 PM
For the last week or so I've been working on measuring and improving the performance of our socket server framework. A long time ago I posted a version of this framework on CodeProject, I then updated it here and here...


The 64000 connection question Posted by Len at 29 Oct 2005 08:46 AM
I've been spending some time pushing the limits of my IO Completion Port based socket server framework to see how many connections my servers can handle and what happens when system resources run out. Earlier postings on the subject are...


Assume makes an ass out of u and me Posted by Len at 28 Oct 2005 11:16 PM
But mostly me. ;) During yesterday's investigations into handling lots (30,000+) of socket connections to my server framework I took a few things for granted. I should have been a bit more thorough rather than just assuming I knew what...


Handling lots of socket connections Posted by Len at 27 Oct 2005 11:10 AM
I'm doing some research for a potential client. They need a TCP/IP server that handles 'lots' of concurrent connections. Their own in-house server code currently fails at 4-6000 connections and I'm putting together a demo for them of how my...


Lock Free Posted by Len at 7 Sep 2005 04:27 PM
I just ran my OpenSSL echo server test harness and ran the server under the deadlock tool. The results are interesting and show that the main source of lock contention on the server is for the lock that protects the...


Be explicit about a class's multiple interfaces Posted by Len at 5 Aug 2005 12:40 PM
I've been working on our socket server framework this week. A client wanted a version of the latest framework with UDP support added. They'd taken the freely available version of the code a couple of years ago and I'd given...


Reprint: Using OpenSSL with Asynchronous Sockets Posted by Len at 4 Aug 2005 01:52 PM
OpenSSL is an open source implementation of the SSL and TLS protocols. Unfortunately it doesn't play well with windows style asynchronous sockets. This article - previously published in Windows Developer Magazine and on my company web site - provides a...


Debugging deadlocks in C++ code with Visual C++ Posted by Len at 28 Jul 2005 04:43 PM
I'm currently adding some functionality to a server that I wrote for a client last year. The server provides application gateway services for them. The new functionality is to switch to using asynchronous connect calls using ConnectEx when it's available...


Disappointing .Net Sockets article in MSDN Magazine this month Posted by Len at 22 Jul 2005 11:22 PM
There's a rather disappointing article on .Net sockets in this month's MSDN magazine....


A single responsibility, please Posted by Len at 20 Jul 2005 06:28 PM
Having got the CMessageProcessor under test in the last posting. I added a few easy tests for the object and then I came to another hard to add test. The reason that it was hard to add was that the...


My own legacy code Posted by Len at 20 Jul 2005 12:34 PM
I've just started work on an ISO8583 server for a client. I've done similar work for them in the past and the first thing that I did was to take the basic shell of the last server that I did...


Winsock, ConnectEx, shutdown, SO_UPDATE_CONNECT_CONTEXT and WSANOTCONN Posted by Len at 16 May 2005 11:18 PM
I'm updating one of the pieces of sample code that we put on CodeProject a couple of years ago. A client wants a version of the COM object socket server that has been built with the latest version of our...


Bug in CThreadPool Posted by Len at 2 Nov 2004 10:51 PM
Bob Etheridge reported a bug in the socket server code from codeproject. He was noticing a small amount of memory corruption on server shutdown. I've narrowed it down to a bug in the CThreadPool class in the Win32 tools library. The bug is present in all versions of the class.
void CThreadPool::ThreadStopped(WorkerThread *pThread)
{
   ::InterlockedDecrement(&m_activeThreads);
   ::InterlockedDecrement(&m_initialisedThreads);
 
   RemoveThreadFromList(pThread);
 
   OnThreadStopped();
}
Should actually be
void CThreadPool::ThreadStopped(WorkerThread *pThread)
{
   ::InterlockedDecrement(&m_activeThreads);
   ::InterlockedDecrement(&m_initialisedThreads);
 
   OnThreadStopped();
 
   RemoveThreadFromList(pThread);
}
This function is called when worker threads shut down. When RemoveThreadFromList() is called for the last active thread an event is set and this causes the main thread to complete its wait for the thread pool to shut down cleanly and continue. This usually results in the thread pool object being destroyed. There's a race condition between the destruction of the object and the completion of the final call to the virtual function OnThreadStopped().


Auction Server Performance Posted by Len at 22 Oct 2004 06:48 PM
I've just about finished the auction server performance tuning. Our thrash test that uses 200 concurrent clients all responding to every bid with a counter bid has gone from averaging 40 incoming bids per second and 3700 outgoing bids per second to 180 incoming and 18000 outgoing. The peak incoming and outgoing were nearer to 1600 and 52000... I'm pretty pleased with the improvements and eventually decided to put the thoughts of lock free list traversal on hold, we don't need it.


Lock Free Posted by Len at 15 Oct 2004 08:09 AM
I'm currently looking at "lock free" access to the linked list that stores the set of clients to communicate with. Ideally we'll be able to add to, delete from and traverse the list from multiple threads without needing to lock and synchronise. There are lots of references available, so far these two (1 and 2) look good from a quick scan of them whilst they were printing... Wish I'd kept up my ACM membership as it looks like the definitive works are available as conference proceedings on their site (then again, I often find that the definitive work isn't necessarily the best starting point). I know that if I get this working here then "SenderX" from the Winsock newsgroups is going to pester me to add it to the rest of the framework's locking list manipulation. More as it happens...


More Socket Server Refactoring Posted by Len at 14 Oct 2004 11:10 PM
I'm currently working on a simple auction server for a client. You can think of it as a specialised chat server, of sorts. One of the things it must do is broadcast messages from one user to a set of users. This is relatively easy to implement in a crude way in our socket server framework but it's not nice. Time to refactor towards niceness...


DRY Posted by Len at 28 Jun 2004 10:03 PM
I was visiting a client on Friday to help them integrate a server we'd written for them with some of their existing systems. We had just got everything working nicely when they mentioned, in passing, that they'd occasionally had problems with our service hanging during startup but they couldn't reproduce it. We talked through the problem for a while and then I had an idea; I configured the service incorrectly, so that it would fail during start up and shutdown. It didn't it hung.


A challenge for the .Net boys and girls Posted by Len at 1 Jun 2004 09:48 PM
I'd like to do some comparative performance testing of my TCP/IP socket server framework against a .Net TCP/IP server, but I don't know enough to be able to write a serious TCP/IP server in .Net. Sure, I could use TcpListener to throw together a simple server but I want something built in an efficient, async, "IIS-beating", style. So, if anyone knows where I could find such a beast; or if someone would like to rise to the challenge and write something, please get in touch...


Easy performance improvement for the socket server code Posted by Len at 17 May 2004 05:12 PM
I was discussing the performance of the IOCP socket server framework with someone the other day and realised that there was a reasonably easy way to speed up some types of servers. I coded a first cut of the solution last night and, so far, it shows a small, but noticeable performance gain for no changes to functionality or code outside of the framework.


The perils of premature "re-use" Posted by Len at 11 May 2004 08:41 AM
Back in January I was writing a TCP/IP server for a client that acted as a connection gateway. Just as this project was coming to an end we started on another project which, at first, seemed quite similar; it was a TCP/IP server that provided gateway services. Just as we were starting out with this new project I made a fairly stupid decision and, well, four months later I've almost finished cleaning things up...


In the Zone Posted by Len at 30 Apr 2004 05:35 PM
Where did the last three days go?


Dogfood Posted by Len at 19 Apr 2004 11:37 PM
I've been running my main mail feeds through my POP3 code for several weeks now. All my email gets pulled from the POP3 servers into my home-brew email system, it runs through my hardcoded filters which split "bad" mail from mail that might be good and finally Outlook connects to my mail server and pulls the email from my system back into production quality code land... Occasionally I see 'interesting things' and these either become the focus for swift retesting session or else find their way into FogBugz...


Testing synchronous communications Posted by Len at 26 Mar 2004 03:53 PM
Today I'm doing some work for a client that involves writing some blocking sockets code to talk to one of our servers. Blocking mode fits well with the architecture of the client application they use; we're moving the app from blocking reads on a serial port to blocking reads on a socket and jiggling the protocol it uses a bit. Testing blocking calls is actually a bit harder than testing non blocking calls because hand cranking the mock objects so that your object under test works correctly is harder to do when your test harness is blocked in a call to read() and wont come back to you until the call times out (and the operation that you're trying to test fails) or the read completes...


Async Pop Posted by Len at 25 Mar 2004 10:24 PM
A while back I finally started on the async version of the POP3 client. It ended up as a state machine and seemed to work well. The next step was to write an async version of the mail collector that I used to pull all mail from a mailbox on a server and optionally delete it.


OpenSSL test server certs expired Posted by Len at 15 Mar 2004 10:45 PM
The test certificates that shipped along with the OpenSSL server demo that I posted here have expired. I'll post some new ones shortly.


POPing back Posted by Len at 2 Mar 2004 09:44 PM
Way back in mid November, before we dumped our building's managing agent for being worse than useless and possibly stealing from us, I was working on some POP3 code. I had some down time today so I decided to drop back into it and see if I could move things along a little. In summary, having lots of tests helped...


We'll be right back, after this word... Posted by Len at 1 Mar 2004 08:01 PM
Surprisingly enough the Bluetooth server "technology preview" has generated quite a bit of interest from potential clients, which is nice. In a similar spirit, I'm making the compiled version of our server that uses the OpenSSL Toolkit available for download....


Why I started thinking about obvious complexity Posted by Len at 29 Feb 2004 02:31 PM
So, what brought on those musings on complexity? There's a bug in the recent public release of the socket server framework code. It's in one of the example servers. Some code got snipped out and it shouldn't have been and the result is a memory leak. The code in question doesn't have tests, but that's not the point, it would be hard to write automated tests that would have caught the problem due to the fact that I, as a designer, made an unchangeable decision for the user of the code.


Some thoughts on complexity Posted by Len at 29 Feb 2004 01:57 PM
I find that these days I prefer my complexity to be obvious. Things with hidden complexity aren't any less complex, they're just less obvious. If you make all of your complexity obvious then you know which pieces of code are complex and you can focus your attempts at simplification on the right places...


Implementing the new AcceptEx server Posted by Len at 27 Feb 2004 06:14 PM
Following my tooth brush revelation about AcceptEx earlier in the week I found some time today to test out my ideas. The implementation went pretty smoothly. It was helped by the fact that I had a previous attempt at using AcceptEx floating around. It was helped more by the refactoring that I'd done recently and the fact that it was easy to take the tests I had for the listen/accept version of the socket server code and adjust them to work with the new AcceptEx version.


Bluetooth server demo Posted by Len at 25 Feb 2004 08:57 AM
I'm making the compiled version of our Bluetooth server shell available for download here. The source is not available at this time.


Finally, the penny drops about AcceptEx Posted by Len at 24 Feb 2004 09:25 AM
So there I was, cleaning my teeth, about to get into bed and suddenly I saw a reason for using AcceptEx... I've known about AcceptEx for ages, and even written an article about how to use it but I always thought that it just wasn't something I needed to use in our servers. I'd latched on to the officially advertised reasons for using it and ignored the more subtle advantages...


I always regret leaving the perfmon code out Posted by Len at 20 Feb 2004 09:16 AM
I had one of those "Doh!" moments yesterday. In summary, always put the performance monitoring code in early, looking at a program's vital signs as a jiggly graph can show up all kinds of unexpected things...


Explicit callbacks or virtual methods Posted by Len at 11 Feb 2004 05:26 PM
I'm in a bit of a quandary. I'm writing a class that does processing on a byte stream. You poke bytes in, it does stuff, it gives you bytes out. My quandary revolves around how it gives you the bytes...


Knocked a few things off the list... Posted by Len at 30 Jan 2004 06:48 PM
The refactoring and testing of the socket server code has gone pretty well. It's not complete but at least we have some tests now and the code is broken down into slightly more cohesive lumps...


Ok, I'm curious Posted by Len at 28 Jan 2004 04:43 PM
I get quite a bit of feedback about the socket server code but I don't really know what people are using it for. So, if you can, leave a comment or drop me a mail and tell me....


So, what do these tests look like then? Posted by Len at 28 Jan 2004 11:45 AM
After breaking the socket server into more manageable chunks I started writing the tests. CAsyncSocketConnectionManager is pretty easy to test, it only has one public function; Connect(). So, what exactly do these tests look like?


How useful it could have been if... Posted by Len at 28 Jan 2004 08:36 AM
I'm writing tests for some code. I have a function that I'm testing that looks something like this: bool CAsyncSocket::Read(bool throwOnFailure = false); If C++ allowed us to overload a function call based on return type then we wouldn't need the horrible throwOnFailure wart and the compiler could pick the right version depending on if we try to use the return value or not... So a call like this: bool ok = pSocket->Read(); would return errors and a call like this: pSocket->Read(); would throw exceptions... I know why C++ doesn't support overloads on return type and I accept that the above could be confusing but... I suppose the way around it is to call the functions different things; void CAsyncSocket::Read(); bool CAsyncSocket::TryRead(); Hmm... Undecided...


Hacking our way to the first test Posted by Len at 27 Jan 2004 06:24 PM
So I have some time on my hands and I've decided that the socket server code could do with some tests but before I can do that I need to refactor because the code was written before I became test infected and, well, it's not as good as it could be...


Admitting that your baby's ugly Posted by Len at 27 Jan 2004 11:12 AM
I have a couple of days to myself. We've just shipped some code to a client a couple of days ahead of schedule and we're waiting to recieve a purchase order from another client so I find myself without any client work to do. I've decided to try and refactor the socket server code that we're using a lot right now. Whilst working on the code that we've just shipped I realised that the new code I was writing was much easier to test than the socket server library that formed a major part of the project, so now that I have some time I'm going to try and rectify that. The problem is, it means facing up to some unfortunate facts...


More socket server code updates Posted by Len at 15 Jun 2003 12:21 AM
I've updated the code for two more of the socket server articles. More merging, project file updating, and testing... [NOTE: This code leaks when adjusted to build with Visual Studio 2005. This seems to be due to a bug in...


Socket Server code updates Posted by Len at 13 Jun 2003 03:08 PM
For some time I've been promising to update the socket server articles to use the latest version of my code. Today I finally updated the code for the first article. I'm going to update the article itself soon, but in...