« Role Playing | Socket Servers Archives | Sound and Vision »

TIME_WAIT perfmon counters

| 0 Comments
I've built a small Windows Service which exposes perfmon counters to track sockets in TIME_WAIT state. It can be downloaded from the links later in this post. Back in 2011 I was helping a client look for issues in their systems caused by having too many sockets in a TIME_WAIT state (see here for why this can be a problem). This was affecting their connectivit. Rather surprisingly there seemed to be no way to track the number of sockets in TIME_WAIT using perfmon as there didn't seem to be a counter exposed. A counter would have been useful so…
Back in January 2010 I discovered that if FILE_SKIP_COMPLETION_PORT_ON_SUCCESS is enabled on a datagram socket and a datagram arrives when a read is NOT currently pending and the datagram is bigger than the buffer supplied to the next read operation then no error is returned and the read will never complete. This was confirmed as a Windows bug and I'm pleased to see that it's been fixed in Windows 8 and Server 2012. It's still present in Windows 7 but that actually makes it easier to reason about the behaviour of the flag on the operating system that you're running…
I've just released new versions of my Lock Explorer tools, LID and LIA. This is quite a big release as it increases the number of locking APIs that the tools instrument from 1 to 3. We now track Slim Reader Writer locks and Mutexes. Arguably the tools should always have tracked these, and possibly more API calls, but the tools have always been first and foremost to assist in the development and testing of The Server Framework and, well, we only use Critical Sections. However, that has recently changed as we're now using Slim Reader Writer locks as a…

See what process is using a TCP port in Windows

| 1 Comment
I have clients asking me about this all the time. This article is pretty concise about the tools that you need to use to map an open port to the process that has it open.…
I'm still working on my investigation of the Windows Registered I/O network extensions, RIO, which I started back in October when they became available with the Windows 8 Developer Preview. I've improved my test system a little since I started and now have a point to point 10 Gigabit network between my test machines using two 2 Intel 10 Gigabit AT2 cards wired back to back. My test system isn't symmetrical, that is I have a much more powerful machine on one end of the link than on the other. This makes it somewhat complex to really push the…

RFC 6455: The WebSocket protocol

| 0 Comments
I know I've said this before, but now it's really done... The WebSocket protocol is now an official RFC. There are a small number of changes between RFC 6455 and the draft WebSocket protocol version 17; the only important ones being he addition of two new close status codes. The rest is just a case of tidying up the draft. There will be a 6.5.3 release of The Server Framework to include these changes.…
Before I started to look at RIO for inclusion in The Server Framework I did a quick check on the Microsoft BUILD site to see if there were any sessions that dealt with it specifically, I didn't find any. Once I posted my blog posting I did another check and found this video that deals specifically with RIO. This gives some in depth details of how RIO works and the kinds of performance improvements that Microsoft has witnessed in their labs. It's interesting and impressive. One thing that I hadn't realised is that with RIO, SO_SNDBUF and SO_RCVBUF are…

The WebSocket protocol is done...

| 0 Comments
Version 16 of the draft WebSocket protocol specification was just released and the HyBi mailing list announcement for this version contained the following: Chairs and editors believe that this version is final (before the publication of the RFC). Thank you to everybody who helped to get this completed and for the stimulating discussions on the way. Now feel free to discuss extensions, WebSocket 1.1, etc. :-). There are no major differences between this and version 13 and the version number of the protocol itself stays at 13 so The WebSockets Option Pack supports everything that will be in the…
I've just released The WebSockets Option Pack for The Server Framework and I think it's worth running through why the API that I designed ended up as it did. This will probably end up as part of The Server Framework's WebSockets documentation, which is currently a little sparse.…

The WebSocket protocol - Draft, HyBi 13

| 0 Comments
Another day, another WebSocket protocol draft... That's probably a little unfair actually. Although there have been several drafts in quick succession over the past few weeks the protocol itself has only changed very slightly. The majority of the changes have simply been to the wording and arrangement of the document. I was fairly cynical about the likely quality of the final RFC when I started looking at the 09 draft and then, in search of clarification, started following the HyBi Working Group's mailing list. As I said at the time, there are a lot of interested parties and they…
I'm nearing the end of my WebSockets implementation for The Server Framework and have been dealing with various protocol compliance issues. Whilst I have decent unit test coverage I haven't, yet, sat down and produced compliance specific unit tests which walk through the various parts of the (ever changing) draft RFC and test each aspect. Looking back, I probably should have taken this approach even though the RFC was fluid. Anyway. One of the people involved in the WebSockets Working Group has a nice set of compliance tests for their implementation and they have made these tests are freely…

WebSockets - I miss the TCP half close...

| 2 Comments
As I mentioned here, the WebSockets protocol is, at this point, a bit of a mess due to the evolution of the protocol and the fact that it's being pulled in various directions by various interested parties. I'm just ranting about some of the things that I find annoying... The WebSockets protocol includes a way for the endpoints to shut down the connection. If an endpoint receives a Close frame and that endpoint did not previously send a Close frame, the endpoint MUST send a Close frame in response. It SHOULD do so as soon as is practical. An…
As I mentioned here, the WebSockets protocol is, at this point, a bit of a mess due to the evolution of the protocol and the fact that it's being pulled in various directions by various interested parties. I'm just ranting about some of the things that I find annoying... The WebSockets protocol is designed to be extended, which is all well and good. Extensions can, at present, be formally specified by RFCs or be "private use" extensions with names that are prefixed with an "x-". So far the only "official" extension is the deflate-stream extension that's detailed in the…
I'm currently building a new example server for The Server Framework. This is a variation on one of our proxy server examples for a client that's doing some WebSockets work. The idea is that the server takes an inbound WebSockets connection, creates an outbound TCP connection to the target server and routes data to and from the remote server and the WebSockets client. It's fairly simple stuff to put together once you're up to speed on The Server Framework but my client needed a helping hand and it's another nice example of what you can do with the framework. As I've mentioned before,…
As I mentioned here, the WebSockets protocol is, at this point, a bit of a mess due to the evolution of the protocol and the fact that it's being pulled in various directions by various interested parties. I'm just ranting about some of the things that I find annoying... The client MUST mask all frames sent to the server. A server MUST close the connection upon receiving a frame with the MASK bit set to 0. In this case, a server MAY send a close frame with a status code of 1002 (protocol error) as defined in Section 7.4.1.…
As I mentioned here, the WebSockets protocol is, at this point, a bit of a mess due to the evolution of the protocol and the fact that it's being pulled in various directions by various interested parties. I'm just ranting about some of the things that I find annoying... Back when binary frames were mentioned in the WebSocket protocol specification as a slightly hand wavy "something for the future" and only text frames were actually possible to send and receive using the clients at the time then there MAY (in the strictest RFC meaning of the word) have been…
As I mentioned here, the WebSockets protocol is, at this point, a bit of a mess due to the evolution of the protocol and the fact that it's being pulled in various directions by various interested parties. I'm just ranting about some of the things that I find annoying... The first thing to realise about the WebSockets protocol is that it isn't really message based at all despite what the RFC claims. Clients and servers, after a successful handshake, transfer data back and forth in conceptual units referred to in this specification as "messages". A message is a complete…
I've been working with the WebSocket protocol recently, updating the code that implements the protocol in The Server Framework to the latest version of the draft standard (the HyBi 09 version). Whilst this looks like it's almost a real standard, there are still lots of potentially open issues as can be seen from the HyBi discussion mailing list. It's quite clear from some of the less cohesive parts of the draft spec (and more so from the mailing list) that the protocol is very much a design by committee effort. This is both good and bad: It's good that the protocol…
I have a client who is possibly suffering from TIME_WAIT accumulation issues and I thought that the best way to find out for sure was to get them to add the TIME_WAIT perfmon counter to their normal counter logs so that we could see how and when sockets in TIME_WAIT accumulate on the machine. The problem is that there doesn't seem to be a perfmon counter for this, which is unfortunate, especially since you can easily get the number of established and reset connections from the TCPv4 and TCPv6 performance objects. Since all of this information is available by…
After a week or so of serious dog fooding I've finally got a nice reliable lock inversion detector running as part of my build system for The Server Framework's example servers. Note: the deadlock detector mentioned in this blog post is now available for download from www.lockexplorer.com. The build system has always run a set of 'black box' server tests for each server example as part of the build. These start up the example server in question, run a set of connections against it and shut the server down. This proves that the example servers actually work and has also proved a…
As I mentioned, I've been adjusting my build system and have finally got to the point where my lock inversion detector is suitable to run on all of my example servers during their test phase on the build machines. I'm working my way through the various example server's test scripts and adjusting them so that they use the lock inversion detector, can be easily configured to run the full blown deadlock detector and also can run the servers under the memory profiling test runner that I put together earlier in the week. Note: the deadlock detector mentioned in this blog…

Tangential testing

| 0 Comments
My theorising about the strange memory related failures that I was experiencing with my distributed testing using WinRS have led me to putting together a test runner that can limit the amount of memory available to a process and terminate it if it exceeds the expected amount. With this in place during my server test runs I can spot the kind of memory leak that slipped through the cracks of my testing and made it into release 6.2 of The Server Framework. The idea is that rather than just starting the server we start the server using a monitoring process that first…
See here for details.…

Latest release of The Server Framework: 6.3

| 0 Comments
The latest release of The Server Framework is now available from ServerFramework.com. See here for details.…

ServerFramework.com

| 0 Comments
I've put together a new website for my super scalable, high performance, I/O Completion Port based server framework. This has all of the information that you need to decide if you can use The Free Framework or if you'd prefer to license The Server Framework. There's also a new server example, WASP, which is a pluggable server platform that is available in compiled form and is free for non-commercial use. Over the next few months WASP will evolve to support most of the key features of the various options that are available with The Server Framework such as SSL, Managed hosting, UDP and TCP,…
Back in April I was talking about how the fact that 6.2 allowed you to enable FILE_SKIP_COMPLETION_PORT_ON_SUCCESS meant that some server designs might start to experience recursion that they previously didn't experience. During the testing for the imminent release of 6.3 I managed to hit on just the right combination of build machine, load and test server to actually produce this under test. As I mentioned back in April, this is only a problem (in 6.2) for servers that do all of their work on their I/O threads (an unusual design amongst my clients). Anyway, with a test client that…

6.3 is coming...

| 0 Comments
This evening I kicked off the acceptance tests for version 6.3 of the example servers that ship with The Server Framework; they'll probably take most of the weekend to run, if I'm lucky. The unit tests for all the libraries have already been run through the build machines over the last few days, the release notes are almost done and so I'm now in the final phase of preparing the 6.3 release. Hopefully we're looking at a release date of early next week. Wooo!…
Last time I explained how the managed side of my flexible hosting server architecture was structured. I dealt with the IDL required to generate the COM interfaces which were used to communicate between unmanaged code and managed code and detailed how the custom AppDomainManager object allowed me to load and execute managed code in such a way that it was easy to update the managed applications whilst the server was running. This time I'll cover the unmanaged side of things. This is actually where much of the complexity lives. The code that actually manages the creation and destruction of the…
I'm working on some prototype code right now to improve the "deployment characteristics" of a socket server that I wrote for a client which uses CLR hosting to provide multiple managed applications within a single unmanaged host. The client wants to be able to start, stop and restart individual managed applications within the server so that during development or when a managed application is updated they don't need to restart the whole unmanaged server process to use a new version of a managed application. This is all quite easy to do using separate application domains for each managed "application" within…
I've recently been adjusting my CLR hosting code as a client wanted to be able to host the .Net 4.0 runtime. Previously they were hosting the 2.0 runtime and, as I mentioned a while back, the hosting API has changed with 4.0. Switching to hosting 4.0 was easy enough but being able to fall back to hosting 2.0 on a machine where 4.0 wasn't installed is slightly more complex. It's reasonably obvious (you need to make sure that you call GetProcAddress() to bind to CLRCreateInstance() rather than linking to it at build time), but Brad Wilson has a nice list…

Amusing bug in GetTempPath()

| 0 Comments
Yesterday I had a bug report from a client who had a user that was getting an exception report from their software which simply said "GetTempPath() - Failed to get temp path". Now as error messages go this isn't the best but it comes from some code that has been in my tools libraries for around 10 years and which has never failed before, it has no tests, we're probably lucky that the message didn't just read "TODO" as I'm pretty sure that it's the first time that anyone has ever seen it apart from by reading my source code…
As I mentioned yesterday, I've been doing some performance testing using the command line interface to perfmon to record the results. Today I automated the stuff I was playing with over the weekend and ended up with a script that can set up a perf log trace, install a particular build of a service, run a test from a remote client machine (using winrs) and then stop and remove the perf log and the service. Another script then calls the first script and tells it which versions of the code to test. Once all of the code has been tested…
Whilst profiling my new low contention buffer allocator in a 'real world' situation recently I spent quite a lot of time trying to work out what I was looking for and when it should happen. Since the allocator improves performance by reducing lock contention it only shines when there IS lock contention. I added some more monitoring to the existing buffer allocator so that it can give an indication of when it's going to block during an allocation or release operation (by using TryEnterCriticalSection() followed by a monitoring notification and then an EnterCriticalSection() when the try has failed). This gave…

More performance testing

| 0 Comments
I'm continuing to help my performance obsessed client squeeze more out of his server. As always we've been using perfmon to view the server's performance counters and since we were investigating CPU spikes we were interested in the thread activity counters that the server exposed. The various perfmon enabled example servers that ship with The Server Framework have always exposed counters that show the number of active and processing threads from various thread pools. It's always been useful to see these snapshots of thread activity and with many servers these counters are enough to tune the server to the hardware. This time…

New UDP Server examples

| 0 Comments
The new release of the licensed, high performance, I/O completion port, server framework includes lots of new example clients and servers; the framework now comes with 74 fully working example that showcase various aspects of the framework. Since the UDP side of the framework has undergone a lot of work recently to support filtering and in preparation for the release of several reliable UDP protocols there are lots of new UDP server examples. There are, of course, the examples that have always shipped with the framework, though with this release they've been moved out of the "Simple Servers" example set…
The latest release of The Server Framework gives you the option of building with FILE_SKIP_COMPLETION_PORT_ON_SUCCESS enabled for various parts of the framework. You can enable it for stream and datagram sockets independently and also for the async file reader and writer classes. This option potentially improves performance by allowing overlapped I/O that completes straight away to be handled by the thread that issued the I/O request rather than by a thread that is servicing the I/O Completion Port that the socket or file handle concerned is associated with. This smooths thread scheduling by allowing the thread that is currently active to deal…

Lock free or many locks?

| 0 Comments | 1 TrackBack
I've been working on some performance tuning for a client of mine recently and whilst much of the tuning has been specific to the details of the their particular server design, eventually I can always get to the point where there are some improvements that can be done to the framework itself. It's nice to have a "real world" performance tuning scenario as I find that tuning example servers can be pointless as the example may not match a real world scenario. I'd already upgraded my client to 6.2 (which is part of the reason that 6.2 has been delayed…
There are two bugs in the Performance Counter library and example servers that mean that performance counters built with the library and following the examples shown in the example servers will fail to work correctly when viewed remotely from another machine. What's more the remote instance of perfmon will fail to display any counters from the machine with the broken performance counters installed. The first problem is that the code that checks to see that the process that has loaded the counter dll has the correct privileges to be able to connect to the shared memory segment that is used…
The latest release of The Server Framework is now available. This release includes the following changes. The following changes were made to the libraries. Admin Library - 6.2 We now support Visual Studio 2010. At present the code has only been tested with the beta and release candidate versions. New build configuration options. All of these are enabled by defining the option to 1 in Config.h and disabled by defining them to 0; the default state if you do not do anything in Config.h is shown for each option: JETBYTE_TINY_XML_2_5_3 - enabled by default. From this release TinyXML version 2.5.3 is available…
I'm just finishing a batch of work that will be included in the 6.2 release of my IOCP based, high performance windows client and server framework and which improves the performance of the framework. There are two main improvements; the first is that the filtering API is now completely optional. There are now filtering and non-filtering base classes so that you only need to include filtering support if you need it. This removes a considerable amount of code that was not required for the non-filtering servers and improves performance by a small amount. The framework base classes are now templatised…
As I mentioned a while back I've been looking at incorporating some simple performance gains in the framework by following the advice given over at the Windows Server Performance Team Blog. Specifically the advice from part three of the "Designing Applications for High Performance" series of postings. Whilst I'd done some quick and dirty tests with the FILE_SKIP_COMPLETION_PORT_ON_SUCCESS flag of SetFileCompletionNotificationModes() and all looked good I'm now working my way through my unit tests and adjusting them to work both when this option is enabled and when it's not (completion dispatch changes somewhat when it's enabled and my tests are…
Charles Dickens said it best in A Tale of Two Cities; "It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to heaven, we were all going direct the other way". In short - debugging…

Datagram filtering

| 0 Comments
The filtering API that's built into the stream (i.e. TCP) side of the licensed framework is pretty powerful. It's what the OpenSSL, SChannel and SSPI Negotiate filters use to transform the data as it flows into and out of your server without you needing to do anything special; it's what the flow control filter uses to provide efficient TCP window based flow control; it's what the compression filter uses to compress your data stream; it's what the read timeout filter uses to provide you with asynchronous read timeouts on overlapped I/O and what the connection re-establishment filter uses to automatically…

Writing a custom Wireshark dissector plugin

| 3 Comments
I've been spending a little time recently writing a custom Wireshark dissector plugin for the UDT protocol. This didn't prove to be that difficult once I got over the initial problem of actually getting the Wireshark source to build with VS2008. My problem was that I'd found a CodeProject article which is now slightly out of date and which I followed too closely - setting up the Platform SDK version that the article stated was required. In fact the source code has moved on since then and now needs a later version. Eventually I switched to using the latest Platform…

.Net 4.0 Hosting (again)

| 0 Comments
As I mentioned a while back the CLR Hosting API has changed with .Net 4.0. The new API allows you much more flexibility in loading CLR runtimes and also allows you to load and run multiple different runtimes in a single process. Whilst this is useful if you need to control which runtime runs your code and indispensable if you need to host code that really requires different versions of the runtime and can't all run in the "latest" runtime, I think the times when a user of my CLRHosting libraries will actually need this functionality will be few and…
The licensed version of my freely available I/O Completion Port based, high performance, Windows networking framework provides a whole host of features that the free code doesn't; aside from performance improvements, bug fixes and an active support and development process. These features make writing highly scalable TCP and UDP clients and servers very easy and solve many of the problems that you would come across if you were to start from scratch, either with the Winsock API directly or using something such as boost::asio. Whilst my client/server framework deliberately does not offer cross platform functionality it targets the writing of…

Stream compression

| 0 Comments
Compressing TCP (and reliable UDP) streams is one of the things that often comes up in discussion with clients and I've helped several people implement stream compression using the TCP stream filtering API that's part of The Server Framework. The filtering API is also used to provide SSL security over a stream and for things like asynchronous read timeouts, read sequencing, flow control and automatic reconnects. It's a flexible API and the fact that it's pluggable means that you can pick and choose from the various filters that form part of the framework and add whichever combination you fancy. I'm just finishing…

Latest release of licensed socket server code: 6.1.1

| 0 Comments
The latest release of The Server Framework is now available. This release includes the following changes. Note that this is mainly a bug fix release. The following changes were made to the libraries. Admin Library - 6.1.1 New build configuration options. All of these are enabled by defining the option to 1 in Config.h and disabled by defining them to 0; the default state if you do not do anything in Config.h is shown for each option: JETBYTE_USE_CAPTURE_STACK_BACK_TRACE - enabled by default. Define to 0 to prevent the use of CaptureStackBackTrace() when building for platforms later than Windows XP. Normally we assume…

Talk to the bear

| 0 Comments
In the great tradition of explaining your problem to someone else as a way of fixing it yourself without their help... I've nailed the rotating file log 16010101 bug! The problem was to do with the fact that when there was a new log ready for use and a log message switched it to be the active log it also set the 'next log time' to zero. If a time change notification came along just after this, whilst the 'next log time' was zero then it created a new log due to a bug in the time change handler; a…

Bugs

| 0 Comments
It's been a bit of a week for bugs. First I had a bug report for the really rather old CodeProject socket server COM object. This allows people using VB to create a socket server that uses the free version of The Server Framework. It works well, for what it is, and has been the basis for several custom objects that various clients have needed over the years. The bug involves the 'read string' functionality and either the ATL headers (specifically the narrow to wide character conversion macros) have changed since the code was originally written in 2002 in VC 6.0 or…

.Net 4.0 Hosting

| 0 Comments
I've been playing with Visual Studio 2010 Beta 2 and .Net 4.0, building code, running tests, playing with the IDE, etc. The first issue that I've come across with my existing codebase is that the .Net 2.0 hosting APIs (such as CorBindToRuntimeEx)are now deprecated and there's a whole new way of hosting the CLR. We've been quite successful in hosting the CLR from within our C++ servers, either to provide servers that support a mix of managed/unmanaged plugins as a pluggable high performance windows application server or to provide network protocol support in C++ (such as ENet) with 'business logic'…

Interesting Blog Posts on High Performance Servers

| 3 Comments
There are some interesting blog posts by Rick Vicik over on the Windows Server Performance Team Blog. Most interesting for me is part three of the three part series on "Designing Applications for High Performance". Whilst parts one and two cover some useful ideas they're pretty general. Part three really digs into the implementation of I/O completion ports and how new API calls can help improve performance and reduce locking within the APIs themselves. These two pieces of information were especially interesting to me: "While you don't need an event in the Overlapped structure when using Completion Ports because the…
The release notes for the 6.1 release, whilst complete, don't really highlight the key points of this release. These are as follows: Support for SSPI Negotiate (NTLM and Kerberos) servers and clients - You can now license code which allows you to implement high performance IO Completion based asynchronous servers and clients that support "Windows Authentication" for authentication and security of data transfer. Example clients and servers are available here The example servers which demonstrate how to use per server and per connection timers (as detailed here) are now available here. The JetByte Service Tools library has been completely rewritten…

Latest release of licensed socket server code: 6.1

| 0 Comments
The latest release of The Server Framework is now available. This release includes the following changes. The following changes were made to the libraries. Admin Library - 6.1 We now suppress warning 4370, 'layout of class has changed from a previous version of the compiler due to better packing', in Warnings.h. New build configuration options. All of these are enabled by defining the option to 1 in Config.h and disabled by defining them to 0; the default state if you do not do anything in Config.h is shown for each option: JETBYTE_TRANSLATE_SEH_EXCEPTIONS - enabled by default. When enabled each thread that is…

Tracking down reference counting bugs

| 0 Comments
The Server Framework uses reference counted data buffers and socket objects. These are passed around as part of the asynchronous I/O system in the framework and as they're placed in queues or passed from one thread to another their reference counts are adjusted so that they are automatically cleaned up when they're finished with; but not before. If you're writing a server or client using The Server Framework then you may need to manipulate these reference counts yourself; as with all reference counted objects, there are two simple rules: If you need to hold on to a reference to an object than…

Using Wireshark to debug UDP communication issues

| 2 Comments
A customer of mine has been having some problems with communication between a UDP server and their load test client. The UDP server implements the ENet protocol which provides for reliable data transfer over UDP. Their problem was manifesting as the client not getting some ENet level ACKs for some reliable data. The Wireshark log from the client machine showed the client resending the data when the ENet retransmission timeout expired and also showed that the ACKs for these packets never arrived. The communications continued normally until the client disconnected due to a final timeout for the missing ACK. A…

Testing blocking calls

| 0 Comments
I'm developing the simple client server protocol code that I'm harvesting in a test driven manner. Although the code exists, as such, and I'm harvesting it rather than inventing it from scratch the harvesting is taking the "best" ideas from several similar implementations to create the version that will form part of the framework's example code. As such I'm treating this just like a new development and, mostly, writing my tests first. This has worked well, as usual, and has allowed me to mercilessly refactor whilst I go as I decide to incorporate features from different versions of the protocol…

Tracking invocations

| 0 Comments
The simple client/server request/response protocol that I'm currently harvesting uses the concept of an 'invocation' to tie a request to a response. An id is generated on the client and placed in the request header. The server simply copies the id from the request header to the response header and the client can then match responses to requests. This works nicely but the implementation has evolved with the protocol. The first version used a 4 byte invocation id, allocated an instance of an invocation data class and stored the allocation address of the object as the invocation id. This worked…

Custom client/server request/response protocols

| 1 Comment
Quite often my customers use The Server Framework for both ends of their communication channels. The Server Framework has fully supported developing clients as well as servers for a long time now and although many of my customers build either servers or clients with the framework some build both. One of the things that often comes up in discussions with these customers is how to develop a custom request/response protocol for their servers and clients to communicate with. Now, of course, there's often a perfectly good existing, standard, protocol that they can use. But sometimes, for whatever reason, there isn't, and I sketch out…
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). Things are going well and, in general, using Negotiate or NTLM or Kerberos is easier than using SChannel and the structure that was originally born to work with OpenSSL and then adapted for SChannel works well with the new security providers. It has also been especially useful to have all of the various high level tests that I developed for…

Where's the catch(...)

| 0 Comments
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 at thread boundaries in functions that are either marked as 'no throw' (with throw()) or which are 'implicitly no throw' and in some destructors. Generally these handlers let the user of the framework know about the unexpected exception via a callback. Generally there's not a lot you can do about it except log it and hope to find the cause later. I've always felt…

Allocating page aligned buffers

| 0 Comments
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 you scale better as one of the two problems with scalability at the time was the 'I/O page lock limit'; there's a finite limit to the number of memory pages that can be locked at one time and in some circumstances data in transit via sockets is locked in memory whilst it is sent. Reducing the number of pages used, by making…
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 their outer catch handlers and report the error to the framework user via various mechanisms. This generally works well and, prevents exceptions going unreported but sometimes users want to integrate the framework with code that deals with uncaught structured exceptions in other ways. The latest version of the framework will include two new configuration defines that can be set in the Config.h…

New Windows Services library

| 0 Comments
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 also allows you to run it as a normal executable inside the debugger, etc. It integrates nicely with our Performance Monitoring library for exposing perfmon counters and comes with several example servers that show you how to use it (see here and here). The library hasn't changed much for many years, it was originally put together back in around 1997…

Race condition during service shutdown

| 0 Comments
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 race condition is present in all versions of the Service Library and so far has only been reported by one client. A fix is available, please contact me directly if you need it, or think you need it. The fix will be included in the 6.1 release of The Server Framework which currently has no scheduled release date. Thanks to Richard and…
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 new instance to the previously released instance data structure. The bug is in PerformanceDataBlock.cpp, the else if around line 167 in AllocateObjectInstance() should be changed from: if (pInstance->NameLength == 0 && !pFirstFreeInstance) { pFirstFreeInstance = pInstance; firstFreeInstanceIndex = i; } else if (0 == memcmp( reinterpret_cast<byte *="">(pInstance)+ pInstance->NameOffset, unicodeInstanceName.c_str(), unicodeInstanceNameLength)) { allocationDisposition = ConnectedExisting; to if (pInstance->NameLength == 0 &&…
Often when you're writing a server or client application with The Server Framework you will find yourself needing to perform operations periodically or after a timeout. The Server Framework provides a light-weight timer queue that can be used to schedule timers and that uses minimal system resources so that there's no problem with having multiple timers per connection; even on systems with 10,000 connections.…
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 changes that have gone into v6.0 and these gaming guys are possibly even more hung up on performance than my banking and trading clients. The good news is that the changes in how we convert numbers to strings has drastically improved performance in their debug builds where they have lots of logging going on. The bad news is that performing…

Interesting piece on thread pools

| 0 Comments
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 summary of why The Server Framework's thread pools operate as they do. Note that on Windows you can use IO Completion Ports to manage the work queue into the thread pool and this can keep the number of threads that are scheduled to run at the optimum number so that the pool operates at the 'correct load' for most of the time…

Bug fix for the free server framework code

| 1 Comment
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 was causing his I/O threads to terminate and leaving him with an unresponsive server. Interestingly I've never had this problem reported before and haven't been able to duplicate the issue but I thought it would be useful to publish the fix in case anyone else comes across the problem. His suggested fix is to change the code in CSocketServer::WorkerThread::Run() from…

Custom application servers

| 0 Comments
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 the server, implement a server that either does everything that the customer requires or allows them to easily plug in their business logic and provide a client side library (or two) that makes it easy for the customer to write clients for the server. The Server Framework makes this kind of thing reasonably straight forward; after all, it's what it was designed…

Upgrading to version 6.0

| 0 Comments
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 a 2005 cut of the code; one written in 2005 and one, heavily based on the other, written in 2008. The upgrade is primarily to support windows performance counters on Windows Server 2008 and to allow for x64 builds. These features have been available in The Server Framework for some time but if your systems work (and have been through complex and time consuming…

Excellent article on Non-Paged Pool

| 2 Comments | 2 TrackBacks
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 one of those annoying system wide limits that can sometimes get in the way of servicing a large number of clients as every active I/O operation consumes some non-paged pool. The good news is that on Vista x64 systems and later the way that non-paged pool limits are calculated has changed and the limits are much higher. As I've said…

Highlights of the 6.0 server framework release

| 0 Comments
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 amount of work and restructuring. The new repository is easier to work with and the new code structure is expecially noticable in the way that example servers and clients are now packaged for release. This new example code structure is easier to release from and to grow; which means that it's more likely that new examples will be released. From a user…
The latest release of The 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 for VS.Net (2002) and VS 2003. The directory is now called Admin\Compatibility and you need to copy sal.h to your compiler's include directory if it complains about it being missing. Some more changes with how Admin.h works. Admin.h now requires that a file called Config.h exists in the Admin directory. Config.h is used to store all of your library settings. Admin.h now simply includes TargetWindowsVersion.h and Config.h…

Automatically pruning empty log files

| 0 Comments
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 start up and server shutdown and then nothing until the server had problems. This meant that they were ending up with lots of empty log files as the hourly, or daily, or weekly rotation period would create a new file and most of the time nothing would be written to it. I've just added some code to the logging class…

Testing SChannel code

| 0 Comments
I developed the new SChannel SSL adapter for The 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 complex as the SChannel adapter without tests; though as I noted when I first set out on the development, back in 2001 I'd developed the corresponding OpenSSL adapter without any tests at all... The tests worked well for me this time around and I was able to both learn about the SChannel API that I was using and implement the required code…

Memory leak in SChannel SSL code

| 0 Comments
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 highlights that the SChannel code was somewhat rushed to release before Christmas. I'm working on a fix now and the changes will be included in the 5.2.5 release of the SChannel code. Right now there are only a few clients with the SChannel code anyway and none of you have 5.2.5 and so I'm folding this fix into that release…
The latest release of The 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 No Change. Win32 Tools Library - 5.2.5 No Change. I/O Tools Library - 5.2.5 No Change. Socket Tools Library - 5.2.5 Fixed a bug in the dispatch of JetByteTools::Socket::IStreamSocketCallback::OnConnectionClosed() from within JetByteTools::Socket::CStreamSocket::OnFinalRelease(). We now ensure that the socket's reference count is valid before calling the callback method. Fixed a bug in the suppression of the WSAENOTSOCK error in JetByteTools::Socket::TAsyncSocket::Shutdown() when we know the socket isn't valid at…
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 valid, i.e. it hasn't been previously closed, when the socket is released for the last time then part of the clean up is to close the socket. Your code is informed of this by the OnConnectionClosed() callback being called. However, if this callback IS called as part of socket clean up then you can't call AddRef() on the socket that you're passed…

Shared locks and unique locks

| 0 Comments
In one of the original articles that introduced The Free 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 changed what was to become The Server Framework to use a lock factory which passed out instances of critical sections based on a hashing algorithm applied to a key that the caller supplied. This allows a known set of critical sections to be shared (evenly, we hope) across all connections. This means that we know in advance how many critical sections we're going…
The latest release of The 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. We now compile with /Wall (in VS2005 and later) to enable all warnings, even those that are disabled by default. Of course this means that the list of warnings that we disable in Warnings.h has grown a little. The custom message pragmas are now all prefixed with JETBYTE_, so there's JETBYTE_TODO, etc. This is to prevent name clashes with user code. C++ Tools Library - 5.2.4 Added…

Lock contention

| 1 Comment
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 didn't cause any lock inversions. The tool worked well and I tweaked it a little more to make it run faster (considerably faster actually!) and report better... The speed increase was pretty dramatic and consisted of adding a new option to the tool to prevent it from monitoring lock operations for locks that we have never seen created. This excludes all of…

Goodbye old friend

| 4 Comments
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 from Visual Studio 6 to Visual Studio 2005 seemed to remove several STL related issues. I then did some research and decided that it simply wasn't worth supporting the old compiler any longer if the first thing that I'd do if a client had problems would be to recommend they upgrade the compiler... I've been using Visual Studio 6 since it came…

Asynchronous SChannel Servers

| 0 Comments
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 should prove useful for people who want a tighter integration with Microsoft's Certificate Stores than our current OpenSSL support provides. In many ways the SChannel version of the code is more complex to implement than the OpenSSL version as the OpenSSL SSL_CTX context object deals with data accumulation and record splitting internally; you just push bytes into it and it eventually pushes…
I've had a few questions from users and potential users of The Server Framework about how it compares to other available frameworks. One such framework is ASIO. The first thing to realise is that The Server Framework and ASIO are very different both in design and functionality. ASIO's strengths are that it's cross platform, it provides low-level asynchronous I/O and that it uses a modern C++ design (i.e. lots and lots of templates and 'interesting' call stacks). The Server Framework is purely for Windows (and even then only those variants of Windows that are descended from the Windows NT line). The Server Framework provides a much higher level…

Log file rotation

| 0 Comments
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 are mainly due to the fact that we have some clients who want to automatically create a new log file every so often whilst the server is running. This hasn't been a requirement before because most of our servers don't continually spew out log data. This is probably due to my feelings about debug trace logs, but we simply don't…

Connection collections

| 0 Comments
One of the questions that comes up time and again from users of The 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 manage it yourself. Usually these people want to write some form of chat or gateway server; client A connects to the server and needs to send data to client B who is also connected to the server. This really isn't a terribly hard problem to solve but, as always, the devil is in the details and enough people get it wrong to…

Documentation bug...

| 0 Comments
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, including before you've had a chance to handle the connection establishment event, you might get a connection termination event. and this: Note that it IS possible that you could receive error, client disconnect, connection reset or connection closed events before or during the processing of the connection established callback. Due to this it is advisable not to access per-connection user…

The life of a stream socket connection

| 0 Comments
As I mentioned here I've recently adjusted how socket callbacks are dispatched in The Server Framework.…
The latest release of The 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 Added a check for _WIN32_WINNT >= 0x0600 and JETBYTE_PLATFORM_SDK_VERSION < 0x060A as targetting Vista or later means we enable stuff that's only available in the v6.0a Platform SDK. Added The \ref AdminFAQ "Frequently asked project related questions" page. Having done some more testing, you might need sal.h for VS.Net (2002) and VS 2003. A copy can be found in Admin\VC6Compatibility and you need to copy it to…
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 The Server Framework in complex servers if you don't abide by the rules. Unfortunately, the rules weren't documented until now and, although I knew them, it's probably more accurate to say "I knew of them". In more complex server developments I often went through a phase where I'd put some code in, in the wrong place, and deadlock the server under certain circumstances." The…

Server shutdown in 5.2.1 and 5.2.2

| 0 Comments
There was a change in release 5.2.1 of The 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 the work with regards to connections could be destroyed whilst there were sockets that it managed still in existence. This wasn't usually a problem but it meant that it was possible for a socket to make a callback to code that didn't exist anymore; which is a Bad Thing. This situation has never shown up in real life but when I added continuous…

Memory leak in licensed socket server code

| 0 Comments
Well, of course, the day after I released the 5.2.2 version of The Server Framework 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. The leak that survived 5.2.2 is in CReadSequencingStreamSocketConnectionFilter::FilterSocketReleased() which currently looks like: void CReadSequencingStreamSocketConnectionFilter::FilterSocketReleased( IIndexedOpaqueUserData &userData) { delete userData.GetUserPointer(m_userDataIndex); } and which should look like: void CReadSequencingStreamSocketConnectionFilter::FilterSocketReleased( IIndexedOpaqueUserData &userData) { CInOrderBufferList *pBuffers = *reinterpret_cast<CInOrderBufferList *>(socket.GetUserPointer(m_userDataIndex)); delete pBuffers; } Without the fix the wrong amount of memory is being released and the CInOrderBufferList destructor isn't being called. The reason that this bug survived…
The latest release of The 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 changes were made to the libraries. Admin Library - 5.2.2 Added JETBYTE_MINIMUM_SUPPORTED_WINDOWS_VERSION and JETBYTE_MINIMUM_SUPPORTED_NTDDI_VERSION to Admin.h. These are currently set to _WIN32_WINNT_WIN2K and NTDDI_WIN2K. Added JETBYTE_PLATFORM_SDK_VERSION which you can use to tell the libraries which version of the Platform SDK you're using. This allows us to work around some of the breaking changes that are introduced by some versions of the Platform SDK. Added a copy of…

Write completion flow control

| 0 Comments
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 client can receive within a reasonable time. Rather than simply continuing to send and building up a massive amount of buffered data in the TCP/IP stack the connection filter keeps track of write completions and begins to buffer data for you when there are 'too many' write operations outstanding. This means that the data is buffered in your own memory…

High throughput, low latency

| 0 Comments
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 echo server test harness that I'd extended to use a controllable TCP receive window. The data feed is just a client that generates random data in packets that have simple header, length, sequence number, type and sends it to the server that it's connected to. It doesn't get anything sent back and it uses the various options that I discussed…

Data distribution servers

| 0 Comments
Many of the servers that are built with The 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 the past, we can easily deal with 70,000 concurrent connections with various real world traffic flow patterns and have various test tools that can stress these kinds of servers. As importantly it's easy to place a limit on the number of connections that a server can handle so as to protect the server (and other processes on the same machine) from…

Another ISO 8583 transaction server

| 3 Comments
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 Framework for another ISO 8583 transaction server that I developed for this client back in 2002. It's interesting to look back at the original code and see how the framework has evolved (see here for the latest version), it's also nice to know that the first server is still running nicely and providing customers with the ability to top up their pay…

Socket connection termination

| 4 Comments
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 Server Framework and the result has been some new TODO items for the 5.3 release... When you have an active TCP/IP connection that you wish to terminate cleanly you need to initiate a TCP/IP protocol level shutdown sequence by calling shutdown(). This sends the appropriate packets between the two TCP/IP stacks (server and client) and terminates the connection. Once this is done you can…

Latest release of licensed socket server code: 5.2.1

| 0 Comments
The latest release of The 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 x64. This is the first release built using continuous integration and there have been some project file fixes to fix incorrect output directories, etc so that x64 and x86 builds can be done in complete isolation. The following changes were made to the libraries. Admin Library - 5.2.1 Added an Admin.cpp file which displays details of the settings from Admin.h during a build. Adjusted the SecureCRT.h header…

Major Vista Overlapped I/O change

| 4 Comments
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 a little, and some things have changed a lot. Unfortunately the book doesn't detail the actual changes. Note to publishers; I'd PAY for a slim book that DOES detail the changes between the APIs that are being discussed... Take this throwaway line in the Cancelling Queued Device I/O Requests section of the Asynchronous Device I/O chapter of the latest book:…

Living with continuous integration

| 1 Comment
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 Control itself. For those of you that haven't been following along: First I realised that the latest (1.3) release of Cruise Control .Net wouldn't work for me without some hacking. Then I found that my idea of 'integration' wasn't quite the same as the simplistic situation for which Cruise Control .Net worked best; I have lots of projects and running…
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 which can cause a deadlock if you have your own lock in your derived class which you lock in OnConnectionReset() or other server callbacks and which is also locked when you call into the framework via Write() or other calls. The deadlock is due to the lock sequencing; when calling into the framework your lock is locked and then the…

New release of free Socket Server framework

| 0 Comments
There's a new release of The Server Framework's Free Framework, here. This includes the bug fix that was mentioned here.…

How important is VC6 to you now?

| 0 Comments
I'm working on the next releases of The 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 the framework is becoming a bit of a mission. It's mostly simple template stuff that fails but I find that I keep having to work around VC6 issues. I'm proposing to drop VC6 support from version 5.3 of The Server Framework. The next release, 5.2.1 (which adds VS2008 support) will be the last version with VC6 support included as standard. How much of an issue would that be for…
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 a server framework that was based on the free version of the code and it hasn't been upgraded to the latest version yet. The bug in my client code is also present in the latest (Feb 14 2006) version of the free socket server framework - found here. The bug does NOT affect the licensed version of The Server Framework unless you're…

Performance counter mismatch detection

| 0 Comments
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 compiled to use. As development progresses and new counters are added the counter dll needs to be uninstalled and then reinstalled so that the text strings associated with the counters remain in sync. Before I rewrote my performance counter code it was reasonably easy to spot when this happened in a debug build, the server simply crashed... The problem was…

Bug in overlapped UDP port unreachable errors?

| 5 Comments
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 error gets reported by failing a pending WSARecvFrom() on the same socket by returning 0 bytes from the WSARecvFrom() with an error code of ERROR_PORT_UNREACHABLE. This would be fine if the framework didn't assume that all errors from an overlapped WSARecvFrom should mean that we don't post another read... You may recall from when I was doing some work on making the…

Performance counters that don't show up in perfmon

| 0 Comments
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 daily development for most projects is on my x64 box and I was building the server in x86 mode and although it was registering its counter DLL correctly it was an x86 DLL and the x64 perfmon can't load x86 counter dlls. This is something that I knew all about from when I was developing the new version of the…

OnSocketReleased() weirdness

| 4 Comments
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 lifetime. It's guaranteed to be the last callback ever called for a connection and it's guaranteed not to be called until all references to a connection have been released; so you can't get caught out by other threads still processing other last minute connection shutdown events. Since, by the time OnSocketReleased() is called the connection is dead, you only get passed a…

Continuing a theme...

| 4 Comments
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 forgotten that VirtualAlloc() allocates in terms of the memory allocation granularity of the operating system.... So, at present, the quick and dirty fix that I posted is allocating buffers in blocks of at least 64k of memory... They are, at least, page aligned ;) Thanks for pointing out the error of my ways, comments like this are one of the…

IOBuffer allocation strategy...

| 2 Comments
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 think about using VirtualAlloc to allocate page-aligned memory for the receive buffers? Would it reduce the number of locked pages? I mean if you allocate a buffer of 'page size' using 'new[]' it is very likely that the buffer uses 2 pages instead of 1." This sounds sensible and the change is easy to make, in Buffer.cpp... void *CBuffer::operator new(…

Being wrong.

| 1 Comment
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 claimed that an obscure internal part of The Server Framework wasn't working as he expected it to...…

x64, IOCP, Socket Server framework

| 7 Comments
The x64 version of our I/O completion port based, networking client and server framework, The 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. The changes from that version to the latest version can be found here. The documentation for this version is available online, here. Please be patient, the docs are a work in progress and I know they could be better. This release sees a first cut at full documentation for all of the example servers; see here. Apart from the…

Spolsky's law stikes again...

| 2 Comments
I'm finalising the testing of the x64 version of The Server Framework 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 away (although all existing customer are entitled to all upgrades to The Server Framework free of charge I usually rely on them monitoring this RSS feed and asking for new releases rather than just sending them out; generally only critical bug fixes are worthy of an email notification...). Anyway, there's lots of interest, which is good, I'm always happier when a new release…
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 call CardMaster which did credit card production. The system supported lots of different machines and each of these machines needed different drivers, the drivers were written in C and usually spoke to the machine via a serial port. In the DOS (actually Concurrent DOS, but...) version of the product I'd used structures of function pointers that the driver populated during…
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 brain just wasn't in the right place for what I was supposed to be doing so I picked up one of more interesting the items on my todo list and took a look at that instead... The bulk of the work flowed nicely but then, just at the end things stopped working for no apparent reason... I'd done what was…

Unsequenced socket bug fix

| 0 Comments
I've just fixed a bug in the latest version of The Server Framework (v5.1 - if you dont have docs and a version number then you're < 5). The probelm was that I was being fractionally over-zealous in making things easy for the user... CStreamSocket has a RequestWrite() method that takes a BYTE * and a length. Originally this used to fail if the length was more than the size of a buffer. Then I fixed the problem so that it split the write over multiple buffers. Unfortunately this is the wrong thing to do if write sequencing isn't enabled. So now…

Performance counter rewrite almost complete

| 0 Comments
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 there's a list of 'nice to have' new items that I haven't completed yet. The work was reasonably easy once I got into it. I wasted an afternoon or so trying to understand the original code that I'd hacked a little way back in 2000 and eventually gave up and went to the documentation (and the book from whence the…
So, back in June I discovered that my performance counter library code didn't work on my new Vista x64 development box... The problem seems to be that the code has always been doing things in an undocumented/unsupported way and it's only now that the old way doesn't actually work at all any more... I think I know what I need to do to fix the counter installation problem, use the wonderfully unixy named "lodctr" program (or the API alternative) to load the strings for the performance counters rather than simply shoving them into the registry myself... That means that the…

Reliable UDP

| 6 Comments
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 (ENet) which was in 'C' and integrated it into their server that was written in C++ with my framework. Unfortunately the 'C' API assumed a synchronous 'pull' model for the communications and The Server Framework gave them an asynchronous 'push' model. They called me in to look at the system and improve the performance. The work has been interesting and the conversion from the 'C', synchronous API to C++ async has…

Pluggable log systems

| 0 Comments
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 the years I've been asked to provide high performance logging systems so that they can spew random messages to files and still run at a reasonable speed. I've written and adjusted an asynchronous file writing log file class a couple of times now and it finally ripened to the point where it was time to harvest it. I finally decided…

x64 port - a diversion

| 2 Comments
The x64 port of The 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 their tests really thrash the framework and are good at shaking out any bugs that might be hiding... So, now I'm faced with the monkey work of adjusting all of the other example servers to build cleanly on all platforms and (in addition to the x64 work) to support either IPv4 or IPv6... My problem is that I now support 5 compilers; VC6…

IPv6 support - in anger...

| 0 Comments
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 my new box has IPv6 installed and since porting, building and testing can become a bit dull after a while I've spent a little time this afternoon playing with making sure the example servers are fully IPv6 aware, and, in fact, address type agnostic. The bulk of the code was already address type agnostic, so much so that we've built bluetooth servers…

Performance counter installation on Vista

| 5 Comments
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 was obvious, you got a message box saying that the user had insufficient rights and now, on Vista, this message box lets you try again and it relaunches the application with the "run_as" verb and you get a chance to run it as Admin... The performance counter issue seems more complex. Firstly the counters I use are based on some…

x64 Socket Server framework

| 2 Comments
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 work on porting The Server Framework to x64. So far things are going very smoothly. The main issue is that I have, in the past, tended to overuse size_t when I really mean "a reasonable sized unsigned value". Since size_t doesn't really fit the bill for that on x64 most of the changes I've had to make are to reduce size_t counts…

Graceful close bug...

| 0 Comments
It seems that the latest changes to The 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 this whole clever thing that lets you decide if you want to do a graceful, lingering, close on an I/O thread or simply slam the door and risk losing data and, well, it doesn't seem to work. Once in a while the connections are being closed before they should. The code path hasn't changed much since the first release of the free source…

cvs update -j

| 0 Comments
I've finally got to the point where my latest refactoring of The Server Framework 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 complete pass through my TODO list and subsequent design adjustments. I also managed to have a good crack at a first pass through the "document the code with doxygen" item and the results of that can be found here. The merge and test process has highlighted the next item on my TODO list that I need to look at; "automated…
Except of course, the refactored filters can't actually be layered that well using the design that I outlined in the previous blog posting.…
As I mentioned a while back, the interface that user code had to The 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 have finally bitten the bullet and dived in and refactored the filtering interface so that it's easier to use. The Server Framework has had a filtering interface for a long time, since around 2002 when I added SSL support for a client. The idea was that you should be able to layer services on to the raw TCP byte stream in such a way that…

Cohesive interfaces

| 0 Comments
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 are all of the callback functions that start with OnXXX (and a couple which don't!), there are the filtering functions and there is CreateListeningSocket() call. All three sets are used by different kinds of user. The OnXXX interface is the real callback interface, the filtering interface has been present since the begining but is only currently used by the OpenSSL…

Socket Server code - refactoring

| 2 Comments
After spending some time cleaning up and refactoring away the need to derive from concrete classes in the Win32 and IO libraries that make up The Server Framework, I finally reached the Socket library and applied the same transformations to the interfaces there. This is actually where I hoped to get most value from taking classes that required you to override virtual methods in a derived class and replacing them with explicit virtual callback interfaces that you need to implement. The main gain I was hoping for was that the result would be easier to document, as it is I got that…

Taking my own advice

| 0 Comments
I'm in the middle of making some changes to The 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 advised others of some time ago; avoid unnecesary optionality. It's quite a sweeping change as all through the framework I originally used pointers to socket objects and data buffers when, in 99.9% of cases it would have been more appropriate to use references. The pointers can never be null so, in my view, they should be references. Unfortunately this change pokes out into…

Echoes from the CLR

| 4 Comments
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 on how isolated you want the user code to be). I think I'm pretty much there as far as what I want to demonstrate is concerned; it works and the line between managed and unmanaged code is likely to vary depending on a client's particular requirements so there's little point in extending the example code any further. Hopefully I'll get…

Socket Server that hosts the CLR

| 0 Comments
My investigations into CLR hosting are going well and today I built an echo sever based on The Server Framework and my CLR Hosting helper library. The idea is that the server can deal with the network IO and then hand off the 'real work' to some .Net code. So far the integration is going pretty smoothly....…
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

| 0 Comments
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

| 6 Comments
The latest version of The 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() { if (m_listeningSocket != INVALID_SOCKET) { if (m_connectionLimiter.CanCreateConnection()) { IncrementPendingReceives(); const IFullAddress &address = GetAddress(); IStreamSocketEx *pSocket = AllocateSocket(CreateSocket(address.Type())).Detach(); IBuffer *pBuffer = AllocateBuffer(); pBuffer->SetUserPtr(m_socketIndex, pSocket); PostIoOperation(pBuffer, IO_Accept_Request); } else to this: void CStreamSocketServerEx::PostAcceptRequest() { if (m_listeningSocket != INVALID_SOCKET) { if (m_connectionLimiter.CanCreateConnection()) { IncrementPendingReceives(); const IFullAddress &address = GetAddress(); IStreamSocketEx *pSocket = AllocateSocket(CreateSocket(address.Type())).Detach(); CSmartBuffer buffer(AllocateBuffer()); buffer.Get()->SetUserPtr(m_socketIndex, pSocket); PostIoOperation(buffer.Get(), IO_Accept_Request); } else…
I've just fixed a problem in The Server Framework 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 and then terminates the connection very quickly. The bug could be said to be in the example servers rather than the framework itself but it can be fixed by a change to the framework... In the non AcceptEx() version of the TCP server code, during connection establishment OnConnectionEstablished() is called from the code that processes a successful Accept(). In most of the example servers this virtual function…

Question from a reader

| 0 Comments
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…
I've just made a small change to The Server Framework. 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 to Close() on a socket that has not yet successfully connected. If the call to Close() completes before connection is attempted by the IO thread pool (possible but usually unlikely in normal operation) then the connection failure doesn't currently make its way back to OnOutgoingConnectionFailed() which means that any code you might have in there for dealing with connection failures wont get called...…

Socket Server code - addressing bug fix

| 0 Comments
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 address is invalid. The code currently reads like this: CSocket::InternetAddress::InternetAddress( const unsigned long address, const unsigned short port) { sin_family = AF_INET; sin_port = htons(port); sin_addr.s_addr = htonl(address); } and it should read like this: CSocket::InternetAddress::InternetAddress( const unsigned long address, const unsigned short port) { sin_family = AF_INET; sin_port = htons(port); sin_addr.s_addr = address; } This bug only affects The…

Latest release of socket server code

| 57 Comments
The latest release of the free version of my asynchronous, windows, IOCP based, socket server framework can now be obtained from here at ServerFramework.com. The latest release is really just a bug fix and compiler compatability release. The code now supports Visual Studio 2005 (as well as VC6, Visual Studio .Net (2002) and Visual Studio 2003). I've fixed the memory leak bugs that were present in the ThreadPoolLargePacketEchoServer sample and worked around the iostream leak that's present in the Visual Studio 2005 version of STL. I've also included a set of build configurations for the basic echo server that builds…

More on the socket server VS2005 "leaks"

| 4 Comments
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 thing that interests me most about this leak is that it seems to be more of a 'strange allocation strategy' rather than a leak as I was previously able to get the memory usage to grow to a large amount and then suddenly it dropped back to something reasonable and then started to grow again. The other interesting thing is…
My VoIP client has been stress testing the UDP version of The 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 is that they had been thrashing a server with lots of concurrent datagrams and pushed the machine until it stopped receiving packets due to the resource limitations of the machine being hit (probably either non-paged pool exhaustion or the i/o page lock limit). They then allowed the server to rest for a bit and then resumed the test. The server ignored every packet…

Controlling Time, Take 2

| 5 Comments
Recently I finished developing a high performance ISO-8583 financial transaction authorisation server for a client using The Server Framework and whilst I was running the final black-box tests against the server I realised that these particular tests were dependant on the system date of the machine running the server. The server uses the current time and date to make some decisions on whether it can authorise a particular transaction or not. The date is used to look up some information from a database table. The table contains details of whether a particular competition type is available for entry or not; it has…

TCP/IP Server Failures

| 5 Comments
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

| 2 Comments
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, tended to stop short of demonstrating real world usage. After all, anyone can write an echo server... " Yet here I am, three and a half years later with a huge collection of different kinds of echo server.…

Windows TCP/IP Server Performance

| 20 Comments
For the last week or so I've been working on measuring and improving the performance of The Server Framework. The latest release of the free version of my asynchronous, windows, IOCP based, socket server framework can now be obtained from here at ServerFramework.com. This week I've had several potential new clients asking about performance numbers for various aspects of the system and so I thought it best to do some measuring. To be able to measure I first had to build a tool to help me.…

The 64000 connection question

| 7 Comments
I've been spending some time pushing the limits of The Server Framework, 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 here and here. This morning I fired up one of my older server boxes and ran the server on that rather than on my dev box. It effortlessly managed 64000 concurrent connections. Previously I've had problems getting above ~30000 connections. The machines I've been testing on have been my main development box and my laptop (both are Windows XP…

Assume makes an ass out of u and me

| 9 Comments
But mostly me. ;) During yesterday's investigations into handling lots (30,000+) of socket connections to a server built with The Server Framework I took a few things for granted. I should have been a bit more thorough rather than just assuming I knew what I was doing. Today I did some more tests.…

Handling lots of socket connections

| 6 Comments
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 The Server Framework supports 30000 connections on 1GB of ram before running into non-paged pool restrictions... Whilst doing this I ran into an 'interesting' feature of WSAAccept() (or, perhaps, simply of an LSP that's installed on my machine...).…

Overriding virtual functions, C# is better than C++

| 2 Comments
I've been merging my UDP framework development branch back to main, building all of my example servers and running all of the "black box" server tests for The Server Framework. In doing so I've experienced the pain of changing virtual function signatures. This is one area where C# syntax is definitely better than the C++ syntax...…

Lock Free

| 2 Comments
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 buffer allocator. Every read or write requires a buffer to be allocated and released. The SSL server actually requires more than one buffer for each read and write as passing the data through the SSL connector causes further buffer allocations. Way back when we first started developing our server framework I boosted the performance quite a bit by having the…

Be explicit about a class's multiple interfaces

| 0 Comments
I've been working on The 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 them some hints as to how they could get it to deal with UDP. This worked well for them and they've built a rather large VOIP system on top and now they're having some performance problems. My first suggestion to them was to add some performance counters so that we could see what was going on. They decided that they liked that idea…
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, which was first published in Windows Developer Magazine and then reprinted on my company web site, provides a simple connector that enables you to use OpenSSL asynchronously. A new posting in the blast from the past reprints area. The article is here.…

Threading flames

| 3 Comments
Thanks to Ned Batchelder for pointing out the "discussion" about the pros and cons of multi-threaded programming over on the SQLite newsgroup. The comments on Ned's post are well worth reading; they've provided me with a new blog to subscribe to, Jeff Darcy's Canned Platypus which seems to have lots of the kind of high quality techie stuff that I like. My view on multi-threading is probably pretty obvious given the way my socket server framework is designed...…
I'm currently adding some functionality to a server that I wrote, using The Server Framework, 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 on the platform that the server is running on and to continue to use a blocking connect if ConnectEx isn't available. As I mentioned in the posting back in Feb 2004 the performance counters that we add to these kinds of servers are invaluable in tracking down problems. Unusual life-signs indicate internal wierdness ;) Today I finished making…
There's a rather disappointing article on .Net sockets in this month's MSDN magazine.…

A single responsibility, please

| 0 Comments
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 object is doing a little too much.…

My own legacy code

| 0 Comments
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 for them and update it to use all of latest version of The Server Framework. The next was to start to look at the first of the requirements for the new server. It was then that I realised that I was working with legacy code...…
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 server framework and which supports outbound connections as well as inbound. The work has been going reasonably well until this afternoon when I found I had a problem shutting down the socket connections that I'd opened.…

Bug in CThreadPool

| 0 Comments
Bob Etheridge reported a bug in the socket server code from codeproject, this is probably the oldest version of The Server Framework's Free Framework code. 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…

Auction Server Performance

| 0 Comments
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

| 2 Comments
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…

More Socket Server Refactoring

| 2 Comments
I'm currently working on a simple auction server for a client using The Server Framework. 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 The Server Framework but it's not nice. Time to refactor towards niceness...…

Measure twice, cut once

| 0 Comments
I'm currently working on a small auction server for a client using The Server Framework. It's a relatively simple server, messages come in, are validated and are then broadcast to interested parties and logged. Yesterday we shipped the first cut of the source to them and I was a bit concerned that our simple test app could thrash the server so easily. Admittedly the first cut of the code hadn't been tuned at all and the logging implementation was fairly Mickey Mouse but I was a little concerned. I woke this morning with a list of perf improvements to try. Some of…
The one where I find that you can teach an old dog new tricks and almost use the 'rocks' word.…

DRY

| 0 Comments
I was visiting a client on Friday to help them integrate a server we'd written for them, using The Server Framework, 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

| 0 Comments
I'd like to do some comparative performance testing of The 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...…
I was discussing the performance of The 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"

| 0 Comments
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

| 0 Comments
Where did the last three days go?…

Dogfood

| 2 Comments
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

| 0 Comments
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…

Async Pop

| 3 Comments
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

| 0 Comments
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

| 0 Comments
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...

| 15 Comments
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. This code uses our freely available IOCP server framework and adds SSL support using OpenSSL. We have an SChannel version in the pipeline for those of you who don't want to have anything to do with OpenAnything...…

Why I started thinking about obvious complexity

| 0 Comments
So, what brought on those musings on complexity? There's a bug in the recent public release of The 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

| 0 Comments
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

| 0 Comments
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

| 12 Comments
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

| 0 Comments
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

| 0 Comments
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

| 2 Comments
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...

| 0 Comments
The refactoring and testing of The Server Framework 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

| 4 Comments
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?

| 0 Comments
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...

| 4 Comments
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…

Hacking our way to the first test

| 2 Comments
So I have some time on my hands and I've decided that The Server Framework 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

| 0 Comments
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 Server Framework 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…

James Antill doesn't like TDD

| 0 Comments
And this is why I hate TDD, testing is a great thing. But testing too early is bad, and you are obviuosly doing that. First you need to know what your code has to do in full. For instance even if you wanted to have both sync. and async. APIs (I personally abhore sync. APIs due to non-scalability) the obvious implementation is to have something like... James Antill - in a comment on my Tangled Testing entry. James, I disagree...…

Harvest Time

| 0 Comments
I had a bit of spare time today so I finished the POP3 server integration. It went nice and smoothly and I tested the result with telnet and Outlook. During the Outlook testing I noticed the 'this server requires a secure connection (SSL)' checkbox. I hadn't been aware that there was a standard port (995) for accessing a POP3 server over SSL. My server currently only supports port 110 for unencrypted transport but I've got code that can turn my server into an SSL enabled server... Looks like it's time to harvest that into The Server Framework.…

More socket server code updates

| 49 Comments | 1 TrackBack
The latest release of the free version of my asynchronous, windows, IOCP based, socket server framework can now be obtained from here at ServerFramework.com. 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 VS2005's STL. See here for a workaround. I expect to post a fix for this once I've found time to convert the code to build with the new compiler and then tracked down the leak. If…

Socket Server code updates

| 102 Comments
The latest release of the free version of my asynchronous, windows, IOCP based, socket server framework can now be obtained from here at ServerFramework.com. 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 the meantime I'm posting the new code here. [NOTE: This code leaks when adjusted to build with Visual Studio 2005. This seems to be due to a bug in VS2005's STL. See here for a workaround.…

Just in time requirements

| 0 Comments
I'm currently developing an online game for a client using The Server Framework. I didn't realise that it was an online game when they originally contracted me. It's become a useful example of emergent requirements. Each time I think the project is complete they come back to me and say "and now we want you to quote for doing X"...…

Using OpenSSL with Asynchronous Sockets

| 22 Comments
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 now available on the Dr. Dobbs site - provides a simple connector that enables you to use OpenSSL asynchronously. Note: If you need high performance SSL over TCP/IP then this is available as an optional part of The Server Framework; see here for details.…
« Role Playing | Socket Servers Archives | Sound and Vision »

About this Archive

This page is an archive of all entries in the Socket Servers category.

Role Playing is the previous category.

Sound and Vision is the next category.

I usually write about C++ development on Windows platforms, but I often ramble on about other less technical stuff...

Find recent content on the main index or look in the archives to find all content.

I have other blogs...

Subscribe to feed The Server Framework - high performance server development
Subscribe to feed Lock Explorer - deadlock detection and multi-threaded performance tools
Subscribe to feed l'Hexapod - embedded electronics and robotics
Subscribe to feed MegèveSki - skiing