Without looking at any of your code (which isn't formatted/indented so I can't be bothered, tbh), in all probability you need to set up port forwarding on your router.
Without that, its safe to assume that no TCP client/server code will work.
Without that, its safe to assume that no TCP client/server code will work.