sockets – Set python 3 server to take action after receiving tcp packet on that port

I have set up a server using Python3. Which will be listening on a specific port. From the client-side, I want to send a TCP request using hping3. I want to set the server in such a way so that it should perform some actions after receiving that TCP request. Looking for ideas to do that.

Thanks In advance.