Can anyone help me get started with a few lines of code that will help my app catch data inbound tcp data and route to an outbound com port?

I want the app to catch a "1" via tcp which the app will identify and send a corresponding string to a specified com port.

I think i've got the com portion down. I just need to know how to integrate the TCP portion. any pointers are appreciated.

Thanks
CM