Three-way-handshake in rule

Hi all,
I am trying to build a rule to send a command to my projector.
The projector is a JVC X30 and the manual explains the following logic to control it:

In order to control it via LAN, you have to establish a TCP-connection via a “3-way-handshake”. It is necessary for a connection authentication to send from the projector “PJ__OK” and - within 5 seconds after sending a “PJREQ” – to receive “PJACK”. Please perform this operation – after con rming the operating status of the projector - again after establishment of a TCP connection, if you cannot send within 5 seconds “PJ__NG” or could not receive “PJNAK”.
After receiving the “PJACK” you can send your command and wait for the answer.

In order to ask to the projector its power status I need to:

  • open a TCP socket to 192.168.1.33 port 20554
  • wait for “PJ_OK”
  • send “PJREQ” within 5 seconds
  • wait for “PJACK”
  • send (in hex) “3F 89 01 50 57 0A”
  • wait for the ack (in hex) “06 89 01 50 57 0A”
  • finally wait for answer (in hex): “40 89 01 50 57 31 0A”
    ( The answer in this case is “31”).

How can I build this into a rule?

Thanks