This site has simple solutions for TCP and UDP servers that you can use to establish if what you are doing is correct.

A Simple Java TCP Server and TCP Client | systemBash