Server Application code (port.cpp)
Port::Port(unsigned port, unsigned baud) : DefaultTimeout(1000) {
sprintf(buf, "COM%i", port);
if( (handle = CreateFile(buf,
GENERIC_READ | GENERIC_WRITE,
0)) == INVALID_HANDLE_VALUE ) {
GetCommState(handle, &commState);
commState.BaudRate = baud;
commState.Parity = NOPARITY;
Port::Write(const void* buf, unsigned szBuf) {
WriteFile(handle, buf, szBuf, &check, 0);