How to validate if a client network printer online?

Hello,

I'm working on a ZPL application for one of my client.

My application requirement is running ZPL application in one printer and get the output label in another printer.

Both printers are on same network.

My application is working fine, so far if both printers connected and live on the network.

But if either one disconnected from network, the application freezes or sometime the Main printer sends the job and it will be in the queue until client printer comes online.

I'm using CLIENSOCKET to perform this task.

My requirement is if anyone could share and help me with ZPL code on how to validate the client printer if it is online or not before I send print job from master printer?

Thanks in advance!,