Python Prompts Free Prompt

Python Script to Monitor Network Connections

Write a Python script that lists current network connections using psutil
☆ Save
Prompt
You are a Python developer. Write a script that uses psutil to list all network connections (TCP/UDP). The script must: 1) Get connections, 2) Filter by state (LISTEN, ESTABLISHED), 3) Display local and remote addresses, 4) Log to file, 5) Run continuously, 6) Alert on suspicious connections, 7) Add comments.

How to use this prompt

1
Click Copy Prompt above to copy to your clipboard.
2
Open ChatGPT, Claude, Gemini, or any AI assistant and paste the prompt.
3
Replace any [PLACEHOLDER] values with your specific details.
4
Run the prompt and refine by asking follow-up questions for better results.