You have to listen on a port on your local PC, but in order for some other client in the internet to connect to you, you need to forward the port on your router to your local PC.
If you don't know what NAT and port forwarding is and have general trouble understanding the basics of networking, I suggest to invest a bit more time in researching the topic. It's a bit more complex and you can't really use a "trial-and-error" message to learn how to write network code.