Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to check if a network port is open using python

import socket 

def port_check(HOST):
   s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
   s.settimeout(2) #Timeout in case of port not open
   try:
      s.connect((HOST, 22)) #Port ,Here 22 is port 
      return True
   except:
      return False

port_check("127.0.1.1")
Comment

PREVIOUS NEXT
Code Example
Python :: get output of ps aux grep python 
Python :: pygame python3.8 
Python :: python list add if not present 
Python :: open a filename starting with in python 
Python :: stringf replcae in python 
Python :: python plot_confusion_matrix 
Python :: python append to file 
Python :: python read_excel index_col 
Python :: format numbers in dataframe pandas 
Python :: which python mac 
Python :: python blackjack 
Python :: ignore bad lines pandas 
Python :: strftime python 
Python :: dopleganger 
Python :: how to provide default value when assign i ngvariables python 
Python :: what is the meaning of illiteral with base 10 
Python :: pickle save 
Python :: upgrade python to 3.9 i linux 
Python :: grid search python 
Python :: python parse dict from string 
Python :: is there a replacement for ternary operator in python 
Python :: python immutable default parameters 
Python :: fig title python 
Python :: how to sort a dictionary by value in python 
Python :: how to run a .exe through python 
Python :: spacy frenc hlemmatizer 
Python :: youtube to mp3 python 
Python :: The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256 
Python :: repeat 10 times python 
Python :: cons(a, b) constructs a pair, and car(pair) and cdr(pair) returns the first and last element of that pair. For example, car(cons(3, 4)) returns 3, and cdr(cons(3, 4)) returns 4. 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =