Simple-Port-Scanner-Python I have used socket library you can manipulate the source code and write your own