TCP Python Server



I am trying to set up a python server on cloud 9 that listens for incoming connections and responds with various messages when it receives data. I would like to be able to use net cat on mac to connect to and communicate with the server using something like the following code:

nc 8888

This line should connect with the server and be able to send and receive messages. I have tried using socket for python on port 8080 and have been able to connect locally but not externally.

In summary, I’m looking for a snippet of code that will create a server which can push messages to clients when they connect and also react to messages that it receives from clients, and I would like to use net cat to interface with the server


Can you use the environment variables IP and PORT? I see you tried 8080 but IP is usually set to to make it external.


When the python socket was running, I could connect to it via “nc 8080” but only from the cloud 9 side. I was unable to connect from my remote machine using the public IP address.