SimpleNamedPipe is a lightweight C++ library for creating and managing asynchronous named pipe servers on Windows.
The project is distributed under the MIT license. See the LICENSE file for the full text.
For the documentation in Russian, see README-RU.md.
- asynchronous client handling through IO Completion Port;
- runs either in a separate thread or blocking the current one (the
start()
parameter); - supports up to 256 simultaneous clients;
- send queue with limits on message size and count;
- event notifications via callbacks or the
ServerEventHandler
class; - lightweight MQL5 client with optional global callbacks;
- the MQL5 client performs read/write synchronously; call
update()
for polling (e.g., in a timer).
#include "SimpleNamedPipe/NamedPipeServer.hpp"
using namespace SimpleNamedPipe;
int main() {
NamedPipeServer server({"ExamplePipe"});
server.on_message = [&server](int id, const std::string& msg) {
server.send_to(id, "Echo: " + msg);
};
server.start(); // launches the server in a separate thread
std::cin.get(); // waits for Enter
server.stop();
}
#include <SimpleNamedPipe\NamedPipeClient.mqh>
NamedPipeClient pipe;
int OnInit() {
pipe.open("ExamplePipe");
EventSetMillisecondTimer(10);
return INIT_SUCCEEDED;
}
void OnDeinit(const int reason) {
EventKillTimer();
}
void OnTimer() {
pipe.update();
if(pipe.connected())
pipe.write("ping");
}
- Install CMake and a compiler (Visual Studio or MinGW).
- Run
build_all.bat
(orbuild_all_mingw.bat
for MinGW) to build the library and examples. - The
install_mql5.bat
script copies files from theMQL5
directory to all detected MetaTrader 5 terminals.
Example sources reside in the examples
directory.
callback_example.cpp
shows using separate callbacks (on_connected
,on_message
, etc.).universal_event_example.cpp
demonstrates similar logic with a singleon_event
handler.
- Named Pipe Server using Overlapped I/O
- Winsock2 Advanced Named Pipe
- Basics of developing programs for Windows and Linux families (in Russian)
SimpleNamedPipe is released under the MIT license. See LICENSE for details.