C CRITICAL_SECTION in windows2 min read

CRITICAL_SECTION (MSDN) in Windows can be used for thread synchronization. Essentially you can create a variable and limit it’s ownership to one thread at a time.  Something like this

Threads block while waiting for ownership of counter . So only one thread will have access to counter  at a time.

Earlier we have created a TCP server using winsock (https://jijnasu.in/c-tcp-server-in-windows-thread-per-connection/). Let’s make use of CRITICAL_SECTION to count the number of requests served by our server.


GST check digit validation algorithm2 min read

GST number validation is done through 2 steps

  1. Check if there is a character in position of a character and a number in position of a number.
  2. Validate the check digit that is the last character in the GST no. with  Luhn mod N algorithm (https://en.wikipedia.org/wiki/Luhn_mod_N_algorithm)

An implementation in javascript


true  is returned if the GST.no is valid. false  if not.

Comment below if you have any questions.

C TCP Server in Windows – Thread per connection2 min read

A simple TCP server in C (windows). It works in a “thread per connection” way.

Note- I don’t know what I am doing.

TCP client in Node.js

See single threaded windows TCP server using IO Completion Ports – https://github.com/hrishimk/iocp_tcp_server