The C++ framework for developing highly scalable, high performance servers on Windows platforms.

Fequently Asked Questions

  • Why isn't there a way to query the connection manager's connection limiter to see if a connection will succeed?
  • How do I send <insert favourite data structure> to a client?
  • How do I build a server as a Windows Service?
  • How do I shut down a server over the network?
  • How do I limit the 'velocity' of data sent?
  • Can I use OnWriteCompletion() to implement flow control and pacing?
  • How can I get a count of the number of current connections?
  • How can I send data to all or some of the current connections?
  • How do I implement a receive timeout?
  • How can I link with MFC?
  • How can I send a heartbeat message every x seconds?
  • Can I send data to clients from more than one thread at the same time?


How do I send <insert favourite data structure> to a client?
TODO

How do I build a server as a Windows Service?
See the Echo Server Service example server documentation for details. Our Service Tools Library is licensed separately from the base server framework, contact us for details.

How do I shut down a server over the network?
TODO

How do I limit the 'velocity' of data sent?
To limit the speed at which you send data you can use OnWriteCompleted() to drive your data flow from a queue of data that is ready to be sent (see SocketFAQFlowControl for more details). Once you have this working you can use a timer to determine how often you send data and therefore how much data is being sent on the connection within a given time.

With explicit acknowledgements from the remote end of the connection you can be sure of how much data has arrived and how much data is 'in flight' and adjust your velocity accordingly.

Can I use OnWriteCompleted() to implement flow control and pacing?
The OnWriteCompleted() is called when an overlapped write completes. This happens when the data in the buffer that you have provided is either sent "onto the wire" or copied into buffers within the TCP stack. All that it means is that you can clean up the buffers that you were using for the send operation. It does NOT mean that the data that you have sent has reached the other end of the connection or anything else like that. The data is now in the hands of the TCP stack and it has taken responsibility for delivering it to the other end of the connection, once there the other end's TCP stack will take responsibility for delivering the data to the application that is using the socket.

So, now that that's clear, it should be fairly obvious that if you want to use TCP's buffering and receieve window (see here for more details) to implement your flow control, for example if you are streaming data to a client, then you can use OnWriteCompleted() to implement this. The trick is in controlling the number of outstanding writes that you allow. When the local TCP stack's buffers are full and the stack has sent the maximum amount of data that it can to the remote stack and is waiting for some ACKs you will find that your Write's will no longer complete until the remote TCP ACKs start to arrive and the stack can send more data. What you must not do is continue to issue writes with abandon as this COULD expose you to the 'locked pages limit' (see here for more details) and your writes will begin to fail with WSAENOBUFS. What you should do is keep track of how many writes you have outstanding (and you should do this yourself rather than trying to hijack the framework's own counter for this!) and pause your data flow on the connection when your have reached a preconfigured number of outstanding writes, once at this point you can then use the completion of your outstanding writes to drive the sending of more data. If you need to fine tune this then you can manipulate the connection's TCP send buffer size (the amount of buffering that the TCP stack will do for you) by calling JetByteTools::Win32::IStreamSocket::SetSendBufferSize().

How can I get a count of the number of current connections?
TODO

How can I send data to all or some of the current connections?
TODO

How do I implement a receive timeout?
Receive timeouts on overlapped reads are not implemented by the operating system. You have to do the work yourself, or use the CReadTimeoutStreamSocketConnectionFilter class. See the Echo Server Read Timeout server example for more details. Note that adding a read timeout using the CReadTimeoutStreamSocketConnectionFilter class does adversely affect the performance of the server, but it should work just fine for servers with a few thousand connections.

How can I link with MFC?
If you really have to link with MFC code (and we hope it's not because you want to put a user interface directly into a server!) then often the library linkage requirements of MFC can be difficult to get right. See here for more details on the likely problems. However we have an example server that demonstrates the use of our Admin Library header file: UsingMFC.h which solves these problems.

How can I send a heartbeat message every x seconds?
TODO

Can I send data to clients from more than one thread at the same time?
TODO


Generated on Sun Sep 12 19:06:45 2021 for The Server Framework - v7.4 by doxygen 1.5.3