Powering Your TCP/IP Socket Server

BWY Systems Server is a library for Windows and Linux that is easily integrated to give your socket server application high performance and stable I/O completion ports capability.

What is I/O Completion Ports (IOCP)?

IOCP (I/O completion ports) is the most high performance socket model available in the programming world. On Microsoft's Windows OS they have provided a set of Win32 API functions for creating various asynchronous socket models such as the event model and overlapped model, but their best conception to date has proven to be the IOCP model. IOCP is designed to be used with a thread pool, where the programmer would create multiple worker threads to service the completed socket events. The way this works is by associating each socket with a handle called a completion port. The worker threads then use this completion port handle to wait for any posted socket events. When one of the socket events completes or finishes, one of the worker threads is then awaken and can be used to process the event (such as sent or received data). After the processing is finished the thread should then wait on the completion port for another event.

This concept is extremely powerful, as never before has a TCP/IP socket server application ever been able to handle so many TCP/IP connections while utilizing such little system resources. If you look back to the basic Berkley socket model, the programmer would normally create a new thread for every connection, which on a high usage application would exhaust the system resources. IOCP is a great leap to more powerful and robust applications.

Under the BWY Systems Server Hood

The BWY Systems Server library exports very simple to use, yet powerful, set of functions that simply mask the complexities of the IOCP code. All of the events are relayed through call back functions that you create and provide when setting up your "Server handle" (the unique handle associated with the listening TCP server you create).